https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e02cdcce68e51f8597b24…
commit e02cdcce68e51f8597b246cd15651cd5e5a1e37f
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sun Oct 20 12:19:51 2019 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun Oct 20 12:46:09 2019 +0200
[MPG123] Update to version 1.25.12. CORE-16440
---
media/doc/3rd Party Files.txt | 2 +-
sdk/include/reactos/libs/libmpg123/config.h | 6 ++---
sdk/include/reactos/libs/libmpg123/mangle.h | 4 ++--
sdk/include/reactos/libs/libmpg123/mpg123.h | 2 +-
sdk/lib/3rdparty/libmpg123/id3.c | 26 ++++++++++++++++-----
sdk/lib/3rdparty/libmpg123/parse.c | 35 ++++++++++++++++++++++-------
6 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/media/doc/3rd Party Files.txt b/media/doc/3rd Party Files.txt
index 820d90305a4..6b646c5092b 100644
--- a/media/doc/3rd Party Files.txt
+++ b/media/doc/3rd Party Files.txt
@@ -63,7 +63,7 @@ Used Version: 0.1.9
Website:
http://www.mega-nerd.com/SRC/download.html
Title: libmpg123 (used by winemp3.acm)
-Used Version: 1.25.10
+Used Version: 1.25.12
Website:
http://www.mpg123.de/
Title: STLport
diff --git a/sdk/include/reactos/libs/libmpg123/config.h
b/sdk/include/reactos/libs/libmpg123/config.h
index 2cda211c7d1..9da8e899bab 100644
--- a/sdk/include/reactos/libs/libmpg123/config.h
+++ b/sdk/include/reactos/libs/libmpg123/config.h
@@ -356,7 +356,7 @@
#define PACKAGE_NAME "mpg123"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "mpg123 1.25.10"
+#define PACKAGE_STRING "mpg123 1.25.12"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mpg123"
@@ -365,7 +365,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.25.10"
+#define PACKAGE_VERSION "1.25.12"
/* Define if portaudio v18 API is wanted. */
/* #undef PORTAUDIO18 */
@@ -398,7 +398,7 @@
/* #undef USE_YASM_FOR_AVX */
/* Version number of package */
-#define VERSION "1.25.10"
+#define VERSION "1.25.12"
/* Define to use Win32 named pipes */
#define WANT_WIN32_FIFO 1
diff --git a/sdk/include/reactos/libs/libmpg123/mangle.h
b/sdk/include/reactos/libs/libmpg123/mangle.h
index 6012ccc3d73..e37386ab009 100644
--- a/sdk/include/reactos/libs/libmpg123/mangle.h
+++ b/sdk/include/reactos/libs/libmpg123/mangle.h
@@ -114,7 +114,7 @@
/* Mach-O binaries (OSX/iOS) */
#define LOCAL_VAR(a) a ## - Lpic_base(_EBX_)
-#define GLOBAL_VAR(a) #error This ABI cannot access non-local symbols directly.
+#define GLOBAL_VAR(a) .err This ABI cannot access non-local symbols directly.
#define GLOBAL_VAR_PTR(a) L_ ## a ## - Lpic_base(_EBX_)
#define FUNC(a) L_ ## a
#define EXTERNAL_FUNC(a) L_ ## a
@@ -130,7 +130,7 @@ Lpic_base: \
/* Dummies for everyone else. */
#define LOCAL_VAR(a) a
#define GLOBAL_VAR ASM_NAME
-#define GLOBAL_VAR_PTR(a) #error Cannot use indirect addressing in non-PIC object.
+#define GLOBAL_VAR_PTR(a) .err Cannot use indirect addressing in non-PIC object.
#define FUNC ASM_NAME
#define EXTERNAL_FUNC ASM_NAME
#define GET_GOT
diff --git a/sdk/include/reactos/libs/libmpg123/mpg123.h
b/sdk/include/reactos/libs/libmpg123/mpg123.h
index ff2138822e1..e830ba33993 100644
--- a/sdk/include/reactos/libs/libmpg123/mpg123.h
+++ b/sdk/include/reactos/libs/libmpg123/mpg123.h
@@ -1,5 +1,5 @@
/*
- libmpg123: MPEG Audio Decoder library (version 1.25.10)
+ libmpg123: MPEG Audio Decoder library (version 1.25.12)
copyright 1995-2015 by the mpg123 project
free software under the terms of the LGPL 2.1
diff --git a/sdk/lib/3rdparty/libmpg123/id3.c b/sdk/lib/3rdparty/libmpg123/id3.c
index eafe004121f..1cc25afd20f 100644
--- a/sdk/lib/3rdparty/libmpg123/id3.c
+++ b/sdk/lib/3rdparty/libmpg123/id3.c
@@ -884,7 +884,8 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
int rva_mode = -1; /* mix / album */
unsigned long realsize = framesize;
unsigned char* realdata = tagdata+pos;
- if((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG))
+ unsigned char* unsyncbuffer = NULL;
+ if(((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG)) &&
framesize > 0)
{
unsigned long ipos = 0;
unsigned long opos = 0;
@@ -892,7 +893,7 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
/* de-unsync: FF00 -> FF; real FF00 is simply represented as FF0000 ... */
/* damn, that means I have to delete bytes from withing the data block... thus
need temporal storage */
/* standard mandates that de-unsync should always be safe if flag is set */
- realdata = (unsigned char*) malloc(framesize); /* will need <= bytes */
+ realdata = unsyncbuffer = malloc(framesize+1); /* will need <= bytes, plus a
safety zero */
if(realdata == NULL)
{
if(NOQUIET) error("ID3v2: unable to allocate working buffer for
de-unsync");
@@ -909,6 +910,8 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
}
}
realsize = opos;
+ /* Append a zero to keep strlen() safe. */
+ realdata[realsize] = 0;
debug2("ID3v2: de-unsync made %lu out of %lu bytes", realsize,
framesize);
}
pos = 0; /* now at the beginning again... */
@@ -936,14 +939,24 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
if(fr->rva.level[rva_mode] <= rva2+1)
{
pos += strlen((char*) realdata) + 1;
- if(realdata[pos] == 1)
+ // channel and two bytes for RVA value
+ // pos possibly just past the safety zero, so one more than realsize
+ if(pos > realsize || realsize-pos < 3)
+ {
+ if(NOQUIET)
+ error("bad RVA2 tag (truncated?)");
+ }
+ else if(realdata[pos] == 1)
{
++pos;
/* only handle master channel */
debug("ID3v2: it is for the master channel");
/* two bytes adjustment, one byte for bits representing peak - n bytes, eh
bits, for peak */
- /* 16 bit signed integer = dB * 512 ... the double cast is needed to
preserve the sign of negative values! */
- fr->rva.gain[rva_mode] = (float) ( (((short)((signed char)realdata[pos]))
<< 8) | realdata[pos+1] ) / 512;
+ /* 16 bit signed integer = dB * 512. Do not shift signed integers! Multiply
instead.
+ Also no implementation-defined casting. Reinterpret the pointer to signed
char, then do
+ proper casting. */
+ fr->rva.gain[rva_mode] = (float) (
+ ((short)((signed char*)realdata)[pos]) * 256 + (short)realdata[pos+1] ) /
512;
pos += 2;
if(VERBOSE3) fprintf(stderr, "Note: RVA value %fdB\n",
fr->rva.gain[rva_mode]);
/* heh, the peak value is represented by a number of bits - but in what
manner? Skipping that part */
@@ -964,7 +977,8 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
break;
default: if(NOQUIET) error1("ID3v2: unknown frame type %i", tt);
}
- if((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG)) free(realdata);
+ if(unsyncbuffer)
+ free(unsyncbuffer);
}
#undef BAD_FFLAGS
#undef PRES_TAG_FFLAG
diff --git a/sdk/lib/3rdparty/libmpg123/parse.c b/sdk/lib/3rdparty/libmpg123/parse.c
index e0059a7feea..8bd679278b2 100644
--- a/sdk/lib/3rdparty/libmpg123/parse.c
+++ b/sdk/lib/3rdparty/libmpg123/parse.c
@@ -1063,18 +1063,29 @@ static int handle_apetag(mpg123_handle *fr, unsigned long
newhead)
unsigned char apebuf[28];
unsigned long val;
int i, ret;
-
+ /* How many bytes to backpedal to get back to just after the first byte of */
+ /* the supposed header. */
+ int back_bytes = 3;
fr->oldhead = 0;
+ debug1("trying to read remaining APE header at %"OFF_P,
(off_p)fr->rd->tell(fr));
/* Apetag headers are 32 bytes, newhead contains 4, read the rest */
- if((ret=fr->rd->fullread(fr,apebuf,28)) < 0) return ret;
-
+ if((ret=fr->rd->fullread(fr,apebuf,28)) < 0)
+ return ret;
+ back_bytes += ret;
+ if(ret < 28)
+ goto apetag_bad;
+
+ debug1("trying to parse APE header at %"OFF_P,
(off_p)fr->rd->tell(fr));
/* Apetags start with "APETAGEX", "APET" is already tested. */
if(strncmp((char *)apebuf,"AGEX",4) != 0)
goto apetag_bad;
/* Version must be 2.000 / 2000 */
- val = (apebuf[7]<<24)|(apebuf[6]<<16)|(apebuf[5]<<8)|apebuf[4];
+ val = ((unsigned long)apebuf[7]<<24)
+ | ((unsigned long)apebuf[6]<<16)
+ | ((unsigned long)apebuf[5]<<8)
+ | apebuf[4];
if(val != 2000)
goto apetag_bad;
@@ -1084,14 +1095,22 @@ static int handle_apetag(mpg123_handle *fr, unsigned long
newhead)
goto apetag_bad;
/* Looks good, skip the rest. */
- val = (apebuf[11]<<24)|(apebuf[10]<<16)|(apebuf[9]<<8)|apebuf[8];
- if((ret=fr->rd->skip_bytes(fr,val)) < 0) return ret;
+ val = ((unsigned long)apebuf[11]<<24)
+ | ((unsigned long)apebuf[10]<<16)
+ | ((unsigned long)apebuf[9]<<8)
+ | apebuf[8];
+ debug2( "skipping %lu bytes of APE data at %"OFF_P
+ , val, (off_p)fr->rd->tell(fr) );
+ /* If encountering EOF here, things are just at an end. */
+ if((ret=fr->rd->skip_bytes(fr,val)) < 0)
+ return ret;
return PARSE_AGAIN;
apetag_bad:
- if(fr->rd->back_bytes(fr,31) < 0 && NOQUIET)
- error("Cannot seek 31 bytes back!");
+ debug("no proper APE tag found, seeking back");
+ if(fr->rd->back_bytes(fr,back_bytes) < 0 && NOQUIET)
+ error1("Cannot seek %d bytes back!", back_bytes);
return PARSE_AGAIN; /* Give the resync code a chance to fix things */
}