libsndfile: update to 1.0.19 (LBSNDF-7)

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0186
http://www.mega-nerd.com/libsndfile/libsndfile-1.0.19.tar.gz

This will likely require a fresh boostrap to updated source checkouts.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13415 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2009-05-21 21:09:30 +00:00
parent d875d23de5
commit 77fab7603a
252 changed files with 28081 additions and 6032 deletions

View File

@@ -1,5 +1,5 @@
/*
** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -34,9 +34,13 @@
#define BUFFER_LEN (1 << 10)
#define LOG_BUFFER_SIZE 1024
static void string_test (const char *filename, int typemajor) ;
static void string_start_test (const char *filename, int typemajor) ;
static void string_start_end_test (const char *filename, int typemajor) ;
static void string_multi_set_test (const char *filename, int typemajor) ;
static void string_rdwr_test (const char *filename, int typemajor) ;
static void string_short_rdwr_test (const char *filename, int typemajor) ;
static int libsndfile_str_count (const char * cptr) ;
static int str_count (const char * haystack, const char * needle) ;
int
main (int argc, char *argv [])
@@ -48,6 +52,8 @@ main (int argc, char *argv [])
printf (" Where <test> is one of the following:\n") ;
printf (" wav - test adding strings to WAV files\n") ;
printf (" aiff - test adding strings to AIFF files\n") ;
printf (" flac - test adding strings to FLAC files\n") ;
printf (" ogg - test adding strings to OGG files\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -55,12 +61,57 @@ main (int argc, char *argv [])
do_all =! strcmp (argv [1], "all") ;
if (do_all || ! strcmp (argv [1], "wav"))
{ string_test ("strings.wav", SF_FORMAT_WAV) ;
{ string_start_end_test ("strings.wav", SF_FORMAT_WAV) ;
string_multi_set_test ("multi.wav", SF_FORMAT_WAV) ;
string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV) ;
string_short_rdwr_test ("short_rdwr.wav", SF_FORMAT_WAV) ;
string_start_end_test ("strings.wavex", SF_FORMAT_WAVEX) ;
string_multi_set_test ("multi.wavex", SF_FORMAT_WAVEX) ;
string_rdwr_test ("rdwr.wavex", SF_FORMAT_WAVEX) ;
string_short_rdwr_test ("short_rdwr.wavex", SF_FORMAT_WAVEX) ;
string_start_end_test ("strings.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
string_multi_set_test ("multi.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
string_rdwr_test ("rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
string_short_rdwr_test ("short_rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "aiff"))
{ string_test ("strings.aiff", SF_FORMAT_AIFF) ;
{ string_start_end_test ("strings.aiff", SF_FORMAT_AIFF) ;
/*
string_multi_set_test ("multi.aiff", SF_FORMAT_AIFF) ;
string_rdwr_test ("rdwr.aiff", SF_FORMAT_AIFF) ;
string_short_rdwr_test ("short_rdwr.aiff", SF_FORMAT_AIFF) ;
*/
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "flac"))
{ if (HAVE_EXTERNAL_LIBS)
string_start_test ("strings.flac", SF_FORMAT_FLAC) ;
else
puts (" No FLAC tests because FLAC support was not compiled in.") ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "ogg"))
{ if (HAVE_EXTERNAL_LIBS)
string_start_test ("vorbis.oga", SF_FORMAT_OGG) ;
else
puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ puts ("\n\n **** String test not working yet for RF64 format. ****\n") ;
/*
string_start_end_test ("strings.rf64", SF_FORMAT_RF64) ;
string_multi_set_test ("multi.rf64", SF_FORMAT_RF64) ;
string_rdwr_test ("rdwr.rf64", SF_FORMAT_RF64) ;
string_short_rdwr_test ("short_rdwr.rf64", SF_FORMAT_RF64) ;
*/
test_count++ ;
} ;
@@ -82,14 +133,20 @@ main (int argc, char *argv [])
static const char
software [] = "software (libsndfile-X.Y.Z)",
artist [] = "The Artist",
copyright [] = "Copyright (c) 2001 The Artist",
copyright [] = "Copyright (c) 2001 Artist",
comment [] = "Comment goes here!!!",
date [] = "2001/01/27" ;
date [] = "2001/01/27",
album [] = "The Album",
license [] = "The license",
title [] = "This is the title",
long_title [] = "This is a very long and very boring title for this file",
long_artist [] = "The artist who kept on changing its name" ;
static short data_out [BUFFER_LEN] ;
static void
string_test (const char *filename, int typemajor)
string_start_end_test (const char *filename, int typemajor)
{ const char *cptr ;
SNDFILE *file ;
SF_INFO sfinfo ;
@@ -97,21 +154,12 @@ string_test (const char *filename, int typemajor)
typemajor = typemajor ;
print_test_name ("string_test", filename) ;
print_test_name ("string_start_end_test", filename) ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
switch (typemajor)
{ case SF_FORMAT_WAV :
sfinfo.format = (typemajor | SF_FORMAT_PCM_U8) ;
break ;
default :
sfinfo.format = (typemajor | SF_FORMAT_PCM_S8) ;
break ;
} ;
sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
frames = BUFFER_LEN / sfinfo.channels ;
@@ -130,6 +178,8 @@ string_test (const char *filename, int typemajor)
sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
sf_set_string (file, SF_STR_COMMENT, comment) ;
sf_set_string (file, SF_STR_DATE, date) ;
sf_set_string (file, SF_STR_ALBUM, album) ;
sf_set_string (file, SF_STR_LICENSE, license) ;
sf_close (file) ;
@@ -163,7 +213,7 @@ string_test (const char *filename, int typemajor)
printf (" Bad software : %s\n", cptr) ;
} ;
if (libsndfile_str_count (cptr) != 1)
if (str_count (cptr, "libsndfile") != 1)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad software : %s\n", cptr) ;
@@ -192,6 +242,31 @@ string_test (const char *filename, int typemajor)
} ;
} ;
switch (typemajor)
{ case SF_FORMAT_AIFF :
case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
case SF_ENDIAN_BIG | SF_FORMAT_WAV :
break ;
default :
cptr = sf_get_string (file, SF_STR_ALBUM) ;
if (cptr == NULL || strcmp (album, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad album : %s\n", cptr) ;
} ;
cptr = sf_get_string (file, SF_STR_LICENSE) ;
if (cptr == NULL || strcmp (license, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad license : %s\n", cptr) ;
} ;
break ;
} ;
if (errors > 0)
{ printf ("\n*** Error count : %d ***\n\n", errors) ;
dump_log_buffer (file) ;
@@ -202,26 +277,332 @@ string_test (const char *filename, int typemajor)
unlink (filename) ;
puts ("ok") ;
} /* string_test */
} /* string_start_end_test */
static void
string_start_test (const char *filename, int typemajor)
{ const char *cptr ;
SNDFILE *file ;
SF_INFO sfinfo ;
int frames, errors = 0 ;
print_test_name ("string_start_test", filename) ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
switch (typemajor)
{ case SF_FORMAT_OGG :
sfinfo.format = typemajor | SF_FORMAT_VORBIS ;
break ;
default :
sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
break ;
} ;
frames = BUFFER_LEN / sfinfo.channels ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
/* Write stuff at start of file. */
sf_set_string (file, SF_STR_TITLE, filename) ;
sf_set_string (file, SF_STR_SOFTWARE, software) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
sf_set_string (file, SF_STR_COMMENT, comment) ;
sf_set_string (file, SF_STR_DATE, date) ;
sf_set_string (file, SF_STR_ALBUM, album) ;
sf_set_string (file, SF_STR_LICENSE, license) ;
/* Write data to file. */
test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
check_log_buffer_or_die (file, __LINE__) ;
if (sfinfo.frames != BUFFER_LEN)
{ printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo.frames, BUFFER_LEN) ;
errors ++ ;
} ;
cptr = sf_get_string (file, SF_STR_TITLE) ;
if (cptr == NULL || strcmp (filename, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad filename : %s\n", cptr) ;
} ;
cptr = sf_get_string (file, SF_STR_COPYRIGHT) ;
if (cptr == NULL || strcmp (copyright, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad copyright : %s\n", cptr) ;
} ;
cptr = sf_get_string (file, SF_STR_SOFTWARE) ;
if (cptr == NULL || strstr (cptr, software) != cptr)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad software : %s\n", cptr) ;
} ;
if (str_count (cptr, "libsndfile") != 1)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad software : %s\n", cptr) ;
} ;
cptr = sf_get_string (file, SF_STR_ARTIST) ;
if (cptr == NULL || strcmp (artist, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad artist : %s\n", cptr) ;
} ;
cptr = sf_get_string (file, SF_STR_COMMENT) ;
if (cptr == NULL || strcmp (comment, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad comment : %s\n", cptr) ;
} ;
if (typemajor != SF_FORMAT_AIFF)
{ cptr = sf_get_string (file, SF_STR_DATE) ;
if (cptr == NULL || strcmp (date, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad date : %s\n", cptr) ;
} ;
} ;
if (typemajor != SF_FORMAT_WAV && typemajor != SF_FORMAT_AIFF)
{ cptr = sf_get_string (file, SF_STR_ALBUM) ;
if (cptr == NULL || strcmp (album, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad album : %s\n", cptr) ;
} ;
} ;
if (typemajor != SF_FORMAT_WAV && typemajor != SF_FORMAT_AIFF)
{ cptr = sf_get_string (file, SF_STR_LICENSE) ;
if (cptr == NULL || strcmp (license, cptr) != 0)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad license : %s\n", cptr) ;
} ;
} ;
if (errors > 0)
{ printf ("\n*** Error count : %d ***\n\n", errors) ;
dump_log_buffer (file) ;
exit (1) ;
} ;
sf_close (file) ;
unlink (filename) ;
puts ("ok") ;
} /* string_start_test */
static void
string_multi_set_test (const char *filename, int typemajor)
{ static const char
new_software [] = "new software (libsndfile-X.Y.Z)",
new_copyright [] = "Copyright (c) 2001 New Artist",
new_artist [] = "The New Artist",
new_title [] = "This is the new title" ;
static char buffer [2048] ;
SNDFILE *file ;
SF_INFO sfinfo ;
int count ;
print_test_name (__func__, filename) ;
sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
/* Write stuff at start of file. */
sf_set_string (file, SF_STR_TITLE, title) ;
sf_set_string (file, SF_STR_SOFTWARE, software) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
/* Write data to file. */
test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
/* Write it all again. */
sf_set_string (file, SF_STR_TITLE, new_title) ;
sf_set_string (file, SF_STR_SOFTWARE, new_software) ;
sf_set_string (file, SF_STR_ARTIST, new_artist) ;
sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
sf_set_string (file, SF_STR_COMMENT, comment) ;
sf_set_string (file, SF_STR_DATE, date) ;
sf_set_string (file, SF_STR_ALBUM, album) ;
sf_set_string (file, SF_STR_LICENSE, license) ;
sf_set_string (file, SF_STR_COPYRIGHT, new_copyright) ;
sf_set_string (file, SF_STR_COMMENT, comment) ;
sf_set_string (file, SF_STR_DATE, date) ;
sf_set_string (file, SF_STR_ALBUM, album) ;
sf_set_string (file, SF_STR_LICENSE, license) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
sf_close (file) ;
count = str_count (buffer, new_title) ;
exit_if_true (count < 1, "\n\nLine %d : Could not find new_title in :\n%s\n", __LINE__, buffer) ;
exit_if_true (count > 1, "\n\nLine %d : new_title appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
count = str_count (buffer, software) ;
exit_if_true (count < 1, "\n\nLine %d : Could not find new_software in :\n%s\n", __LINE__, buffer) ;
exit_if_true (count > 1, "\n\nLine %d : new_software appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
count = str_count (buffer, new_artist) ;
exit_if_true (count < 1, "\n\nLine %d : Could not find new_artist in :\n%s\n", __LINE__, buffer) ;
exit_if_true (count > 1, "\n\nLine %d : new_artist appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
count = str_count (buffer, new_copyright) ;
exit_if_true (count < 1, "\n\nLine %d : Could not find new_copyright in :\n%s\n", __LINE__, buffer) ;
exit_if_true (count > 1, "\n\nLine %d : new_copyright appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
unlink (filename) ;
puts ("ok") ;
} /* string_multi_set_test */
static void
string_rdwr_test (const char *filename, int typemajor)
{ SNDFILE *file ;
SF_INFO sfinfo ;
sf_count_t frames ;
const char * str ;
print_test_name (__func__, filename) ;
create_short_sndfile (filename, typemajor | SF_FORMAT_PCM_16, 2) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
frames = sfinfo.frames ;
sf_set_string (file, SF_STR_TITLE, title) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
frames = sfinfo.frames ;
sf_set_string (file, SF_STR_TITLE, title) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
str = sf_get_string (file, SF_STR_ARTIST) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
sf_close (file) ;
unlink (filename) ;
puts ("ok") ;
} /* string_rdwr_test */
static void
string_short_rdwr_test (const char *filename, int typemajor)
{ SNDFILE *file ;
SF_INFO sfinfo ;
sf_count_t frames = BUFFER_LEN ;
const char * str ;
print_test_name (__func__, filename) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
/* Write data to file. */
test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
sf_set_string (file, SF_STR_TITLE, long_title) ;
sf_set_string (file, SF_STR_ARTIST, long_artist) ;
sf_close (file) ;
/* Open the file RDWR. */
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
str = sf_get_string (file, SF_STR_ARTIST) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, long_artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
/* Change title and artist. */
sf_set_string (file, SF_STR_TITLE, title) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
check_log_buffer_or_die (file, __LINE__) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
str = sf_get_string (file, SF_STR_ARTIST) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
sf_close (file) ;
unlink (filename) ;
puts ("ok") ;
} /* string_short_rdwr_test */
static int
libsndfile_str_count (const char * str)
{ const char * cptr ;
str_count (const char * haystack, const char * needle)
{ int count = 0 ;
if ((cptr = strstr (str, "libsndfile")) == NULL)
return 0 ;
while ((haystack = strstr (haystack, needle)) != NULL)
{ count ++ ;
haystack ++ ;
} ;
if ((cptr = strstr (cptr + 1, "libsndfile")) == NULL)
return 1 ;
return count ;
} /* str_count */
return 2 ;
} /* libsndfile_str_count */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 0260b3db-c250-4244-95a0-d288a913729a
*/