diff options
author | pho <pho@pkgsrc.org> | 2015-01-26 07:26:55 +0000 |
---|---|---|
committer | pho <pho@pkgsrc.org> | 2015-01-26 07:26:55 +0000 |
commit | 56e0bf5707f6d94e621a088b4216e0f6006848db (patch) | |
tree | ab7e931400be02ce26ba5f1ec5dbf12f8445c8b9 | |
parent | 99aa65f232b01eb831a42f4ea6e90077fe5cfbe0 (diff) | |
download | pkgsrc-56e0bf5707f6d94e621a088b4216e0f6006848db.tar.gz |
patches/patch-src_system_Clock.cxx: Avoid integer overflow in MonotonicClock{S,MS,US}
This is Darwin specific: the original implementation was causing an
integer overflow when base.numer was very large. On PPC Darwin, the
timebase is 1000000000/33330116 and this is too large for integer
arithmetic.
http://bugs.musicpd.org/view.php?id=4292
-rw-r--r-- | audio/musicpd/Makefile | 3 | ||||
-rw-r--r-- | audio/musicpd/distinfo | 3 | ||||
-rw-r--r-- | audio/musicpd/patches/patch-src_system_Clock.cxx | 46 |
3 files changed, 50 insertions, 2 deletions
diff --git a/audio/musicpd/Makefile b/audio/musicpd/Makefile index 7551a3bc91f..3911f28fe34 100644 --- a/audio/musicpd/Makefile +++ b/audio/musicpd/Makefile @@ -1,6 +1,7 @@ -# $NetBSD: Makefile,v 1.100 2015/01/18 17:36:21 wiz Exp $ +# $NetBSD: Makefile,v 1.101 2015/01/26 07:26:55 pho Exp $ DISTNAME= mpd-0.19.8 +PKGREVISION= 1 PKGNAME= ${DISTNAME:S/mpd/musicpd/} CATEGORIES= audio MASTER_SITES= http://www.musicpd.org/download/mpd/0.19/ diff --git a/audio/musicpd/distinfo b/audio/musicpd/distinfo index d0f0de86ef1..890dac27938 100644 --- a/audio/musicpd/distinfo +++ b/audio/musicpd/distinfo @@ -1,8 +1,9 @@ -$NetBSD: distinfo,v 1.59 2015/01/26 04:17:53 pho Exp $ +$NetBSD: distinfo,v 1.60 2015/01/26 07:26:55 pho Exp $ SHA1 (mpd-0.19.8.tar.xz) = e5e325b666474bddec6c07502fa2dcf3710a42e3 RMD160 (mpd-0.19.8.tar.xz) = eec522d7a2ba4b91c0d7e2ca44bce3a14313a69d Size (mpd-0.19.8.tar.xz) = 705108 bytes SHA1 (patch-src_output_plugins_httpd_HttpdOutputPlugin.cxx) = b47d79cc49a27d732a7531e23d666bf9df748bec +SHA1 (patch-src_system_Clock.cxx) = fb8aa263c78a15ab942324a987d6429c0b7b41fb SHA1 (patch-src_util_Alloc.cxx) = 81540f213e274fa5b8d064c1c93e660047256961 SHA1 (patch-src_util_Alloc.hxx) = 841c8cf6c1b6a7e46ad0edf1eb31625c0ec6ea66 diff --git a/audio/musicpd/patches/patch-src_system_Clock.cxx b/audio/musicpd/patches/patch-src_system_Clock.cxx new file mode 100644 index 00000000000..38870e21f73 --- /dev/null +++ b/audio/musicpd/patches/patch-src_system_Clock.cxx @@ -0,0 +1,46 @@ +$NetBSD: patch-src_system_Clock.cxx,v 1.1 2015/01/26 07:26:55 pho Exp $ + +Avoid integer overflow in MonotonicClock{S,MS,US} + +This is Darwin specific: the original implementation was causing an +integer overflow when base.numer was very large. On PPC Darwin, the +timebase is 1000000000/33330116 and this is too large for integer +arithmetic. + +http://bugs.musicpd.org/view.php?id=4292 + +--- src/system/Clock.cxx.orig 2015-01-26 06:16:36.000000000 +0000 ++++ src/system/Clock.cxx +@@ -40,8 +40,8 @@ MonotonicClockS(void) + if (base.denom == 0) + (void)mach_timebase_info(&base); + +- return (unsigned)((mach_absolute_time() * base.numer / 1000) +- / (1000000 * base.denom)); ++ return (unsigned)(((double)mach_absolute_time() * base.numer / 1000) ++ / base.denom / 1000000); + #elif defined(CLOCK_MONOTONIC) + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); +@@ -62,8 +62,8 @@ MonotonicClockMS(void) + if (base.denom == 0) + (void)mach_timebase_info(&base); + +- return (unsigned)((mach_absolute_time() * base.numer) +- / (1000000 * base.denom)); ++ return (unsigned)(((double)mach_absolute_time() * base.numer) ++ / base.denom / 1000000); + #elif defined(CLOCK_MONOTONIC) + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); +@@ -104,8 +104,8 @@ MonotonicClockUS(void) + if (base.denom == 0) + (void)mach_timebase_info(&base); + +- return ((uint64_t)mach_absolute_time() * (uint64_t)base.numer) +- / (1000 * (uint64_t)base.denom); ++ return (uint64_t)(((double)mach_absolute_time() * base.numer) ++ / base.denom / 1000); + #elif defined(CLOCK_MONOTONIC) + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); |