diff --git a/.gitignore b/.gitignore index d6ec1e5..feaaf3c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ project/msvc/intermediate/ libfaad/win32_ver.h *.user +/libfaad/faad2.pc diff --git a/ChangeLog b/ChangeLog index 79162b0..92d65c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2.9.2: + [ Michał Janiszewski ] + * Only use x86-assembly when explicitly on x86 + * Use unsigned integers correctly + * Initialize pointers that might otherwise not be + + [ Fabian Greffrath ] + * update README esp. WRT directory structure + + [ Rosen Penev ] + * fix compilation without SBR/PS_DEC (#48) + * fix compilation with LC_ONLY_DECODER (#47) + + [ Fabian Greffrath ] + * fix "inline function 'cfftf1' declared but never defined" compiler warning + * fix some inconsistencies in the frontend output + * mp4read_open: add check for failed frame buffer allocation + * stszin: add check for allocation error and integer overflow + * add a pkg-config file + + [ Stefan Pöschel ] + * frontend: address compile warning + add missing LF (#50) + + [ François Cartegnie ] + * library name is faad (#52) + * Unbreak PS audio (#51) + 2.9.1: [ Fabian Greffrath ] * Include stdio.h in libfaad/ps_dec.c for stderr (Michael Fink) diff --git a/README b/README index c50e110..0cb43fb 100644 --- a/README +++ b/README @@ -48,50 +48,34 @@ ACTIONS! -______ -PEOPLE - -FAAD2 is written by: - - M. Bakker (mbakker(at)nero.com). - - -_______________ -VERSION HISTORY - -Sorry, try building a ChangeLog from CVS. - ___________________ DIRECTORY STRUCTURE faad2 - top level directory. - aacDECdrop - windows decoder/player with drag'n'drop functionality + aacDECdrop - windows decoder/player with drag'n'drop functionality. - common - generally used libraries and code. + docs - API documentation. - faad - general common functions like filereading and streaming - as well as getting info from aac files. - - mp4ff - Small MP4 file format library (includes tagging abilities). - frontend - command line frontend to the FAAD2 library, also supports MPEG-4 file decoding. include - inlude file for the FAAD2 library. libfaad - the FAAD2 AAC decoder library including SBR. - - codebook - Huffman codebooks + + codebook - Huffman codebooks. plugins - plugins for all kinds of pograms. - - in_mp4 - winamp MPEG-4 AAC file input plugin. - + + mpeg4ip - plugin for the mpeg4ip player. + QCD - Quintessential player AAC plugin. QCDMp4 - Quintessential player MP4 plugin. - xmms - xmms AAC plugin + xmms - xmms AAC plugin. - mpeg4ip - plugin for the mpeg4ip player + project/msvc - Visual Studio 2017 project files. + utils/win32 - generate "win32_ver.h" from "configure.h". diff --git a/configure.ac b/configure.ac index 44faa0c..65b3cdd 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ dnl - mpeg4ip plugin (requires mpeg4ip's libmp4v2 to be installed) AC_PREREQ(2.50) -AC_INIT(faad2, 2.9.1) +AC_INIT(faad2, 2.9.2) AC_CONFIG_AUX_DIR(.) AM_INIT_AUTOMAKE([subdir-objects]) @@ -159,6 +159,7 @@ fi AC_CONFIG_FILES(libfaad/Makefile) +AC_CONFIG_FILES(libfaad/faad2.pc) AC_CONFIG_FILES(plugins/Makefile) AC_CONFIG_FILES(plugins/xmms/Makefile) AC_CONFIG_FILES(plugins/xmms/src/Makefile) diff --git a/frontend/main.c b/frontend/main.c index e1d3c7d..fadc5cb 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -462,9 +462,9 @@ unsigned char channels; void *sample_buffer; - audio_file *aufile; - - FILE *adtsFile; + audio_file *aufile = NULL; + + FILE *adtsFile = NULL; unsigned char *adtsData; int adtsDataSize; @@ -796,9 +796,9 @@ long sampleId, startSampleId; - audio_file *aufile; - - FILE *adtsFile; + audio_file *aufile = NULL; + + FILE *adtsFile = NULL; unsigned char *adtsData; int adtsDataSize; @@ -1047,6 +1047,7 @@ char *adtsFileName = NULL; float seekTo = 0; unsigned char header[8]; + int bread; float length = 0; FILE *hMP4File; char *faad_id_string; @@ -1300,16 +1301,21 @@ } } - fread(header, 1, 8, hMP4File); + bread = fread(header, 1, 8, hMP4File); if (! readFromStdin ) fclose(hMP4File); + if (bread != 8) { + faad_fprintf(stderr, "Error reading file.\n"); + return 1; + } + if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p') mp4file = 1; if (!mp4file && seekTo != 0) { - faad_fprintf(stderr, "Warning: can only seek in MP4 files"); + faad_fprintf(stderr, "Warning: can only seek in MP4 files\n"); } if (mp4file) @@ -1351,7 +1357,7 @@ float dec_length = (float)(clock() - begin)/(float)CLOCKS_PER_SEC; #endif faad_fprintf(stderr, "Decoding %s took: %5.2f sec. %5.2fx real-time.\n", aacFileName, - dec_length, length/dec_length); + dec_length, (dec_length > 0.01) ? (length/dec_length) : 0.); } if (aacFileName != NULL) diff --git a/frontend/mp4read.c b/frontend/mp4read.c index 8e6237c..1b24f18 100644 --- a/frontend/mp4read.c +++ b/frontend/mp4read.c @@ -343,10 +343,13 @@ u32in(); // Number of entries mp4config.frame.ents = u32in(); - // fixme error checking // fixme: check atom size mp4config.frame.data = malloc(sizeof(*mp4config.frame.data) * (mp4config.frame.ents + 1)); + + if (!mp4config.frame.data) + return ERR_FAIL; + ofs = 0; mp4config.frame.data[0] = ofs; for (cnt = 0; cnt < mp4config.frame.ents; cnt++) @@ -358,6 +361,9 @@ mp4config.frame.maxsize = fsize; mp4config.frame.data[cnt + 1] = ofs; + + if (ofs < mp4config.frame.data[cnt]) + return ERR_FAIL; } return size; @@ -951,7 +957,7 @@ static void mp4info(void) { - fprintf(stderr, "Modification Time:\t\t%s", mp4time(mp4config.mtime)); + fprintf(stderr, "Modification Time:\t\t%s\n", mp4time(mp4config.mtime)); fprintf(stderr, "Samplerate:\t\t%d\n", mp4config.samplerate); fprintf(stderr, "Total samples:\t\t%d\n", mp4config.samples); fprintf(stderr, "Total channels:\t\t%d\n", mp4config.channels); @@ -1002,8 +1008,10 @@ } // alloc frame buffer - // fixme: error checking mp4config.bitbuf.data = malloc(mp4config.frame.maxsize); + + if (!mp4config.bitbuf.data) + goto err; if (mp4config.verbose.header) { diff --git a/libfaad/Makefile.am b/libfaad/Makefile.am index 8ed57ae..9105625 100644 --- a/libfaad/Makefile.am +++ b/libfaad/Makefile.am @@ -32,5 +32,10 @@ libfaad_drm_la_LDFLAGS = ${libfaad_la_LDFLAGS} libfaad_drm_la_LIBADD = ${libfaad_la_LIBADD} -libfaad_drm_la_CFLAGS = ${libfaad_la_CFLAGS} -DDRM -DDRM_PS +libfaad_drm_la_CFLAGS = ${libfaad_la_CFLAGS} -DDRM_SUPPORT libfaad_drm_la_SOURCES = ${libfaad_la_SOURCES} + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = faad2.pc + +EXTRA_DIST = faad2.pc.in diff --git a/libfaad/cfft.c b/libfaad/cfft.c index 5b01d75..cf18a91 100644 --- a/libfaad/cfft.c +++ b/libfaad/cfft.c @@ -60,8 +60,6 @@ static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch, const complex_t *wa1, const complex_t *wa2, const complex_t *wa3, const complex_t *wa4, const int8_t isign); -INLINE void cfftf1(uint16_t n, complex_t *c, complex_t *ch, - const uint16_t *ifac, const complex_t *wa, const int8_t isign); static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac); diff --git a/libfaad/common.h b/libfaad/common.h index 897a0f0..76722e4 100644 --- a/libfaad/common.h +++ b/libfaad/common.h @@ -91,8 +91,10 @@ /* Allow decoding of LD profile AAC */ #define LD_DEC /* Allow decoding of Digital Radio Mondiale (DRM) */ -//#define DRM -//#define DRM_PS +#ifdef DRM_SUPPORT +#define DRM +#define DRM_PS +#endif /* LD can't do without LTP */ #ifdef LD_DEC @@ -115,6 +117,7 @@ #undef MAIN_DEC #undef SSR_DEC #undef DRM + #undef DRM_PS #undef ALLOW_SMALL_FRAMELENGTH #undef ERROR_RESILIENCE #endif @@ -313,7 +316,7 @@ } - #if defined(_WIN32) && !defined(_WIN64) && !defined(__MINGW32__) + #if defined(_WIN32) && defined(_M_IX86) && !defined(__MINGW32__) #ifndef HAVE_LRINTF #define HAS_LRINTF static INLINE int lrintf(float f) diff --git a/libfaad/decoder.c b/libfaad/decoder.c index 4f4b011..9bed248 100644 --- a/libfaad/decoder.c +++ b/libfaad/decoder.c @@ -239,7 +239,7 @@ while (ld->bytes_left) { bits = faad_latm_frame(latm, ld); - if(bits==-1U) + if(bits==0xFFFFFFFF) bad++; else { diff --git a/libfaad/faad2.pc.in b/libfaad/faad2.pc.in new file mode 100644 index 0000000..e16eaa4 --- /dev/null +++ b/libfaad/faad2.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: FAAD2 +Description: Freeware Advanced Audio (AAC) Decoder +Version: @VERSION@ +Libs: -L${libdir} -lfaad +Libs.private: -lm +Cflags: -I${includedir} diff --git a/libfaad/mp4.c b/libfaad/mp4.c index 9f0198a..dbcff83 100644 --- a/libfaad/mp4.c +++ b/libfaad/mp4.c @@ -33,7 +33,6 @@ #include -#include "bits.h" #include "mp4.h" #include "syntax.h" diff --git a/libfaad/mp4.h b/libfaad/mp4.h index 5a94be4..d99a3e3 100644 --- a/libfaad/mp4.h +++ b/libfaad/mp4.h @@ -35,6 +35,7 @@ extern "C" { #endif +#include "bits.h" #include "neaacdec.h" int8_t AudioSpecificConfig2(uint8_t *pBuffer, diff --git a/libfaad/specrec.c b/libfaad/specrec.c index aeb5d13..c5a563a 100644 --- a/libfaad/specrec.c +++ b/libfaad/specrec.c @@ -915,18 +915,18 @@ /* element_output_channels not set yet */ hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { - /* element inconsistency - * this only happens if PS is actually found but not in the first frame + /* element inconsistency */ + + /* this only happens if PS is actually found but not in the first frame * this means that there is only 1 bitstream element! */ - if (hDecoder->fr_channels == 1) { - /* reset the allocation */ - hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0; - hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; - } else { - return 21; - } + /* reset the allocation */ + hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0; + + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; + + //return 21; } if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) @@ -938,6 +938,9 @@ hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; } + /* sanity check, CVE-2018-20199, CVE-2018-20360 */ + if(!hDecoder->time_out[sce->channel]) + return 15; /* dequantisation and scaling */ retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef, hDecoder->frameLength); @@ -1117,6 +1120,10 @@ hDecoder->element_alloced[hDecoder->fr_ch_ele] = 2; } + + /* sanity check, CVE-2018-20199, CVE-2018-20360 */ + if(!hDecoder->time_out[cpe->channel]) + return 15; /* dequantisation and scaling */ retval = quant_to_spec(hDecoder, ics1, spec_data1, spec_coef1, hDecoder->frameLength); diff --git a/libfaad/syntax.c b/libfaad/syntax.c index c992543..b3d3a85 100644 --- a/libfaad/syntax.c +++ b/libfaad/syntax.c @@ -2644,5 +2644,5 @@ return (len*8)-(endpos-initpos); //faad_getbits(ld, initpos-endpos); //go back to initpos, but is valid a getbits(-N) ? } - return -1U; -} + return 0xFFFFFFFF; +}