1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 08:09:32 +02:00

Fix Bug 448 (P2) - WAV export corrupt if imported file has metadata after data (edit)

Applies patch from libsndfile 1.2.25 on the git repo.

src/strings.c : Fix handling of SF_STR_SOFTWARE that resulted in a segfault.

FYI, The commit has the following properties
commit 386af45517724a1b10a790899c8c4ec2c4b161af
Author: Erik de Castro Lopo <erikd@mega-nerd.com>
Date:   Fri Mar 25 19:12:24 2011 +1100

  src/strings.c : Fix handling of SF_STR_SOFTWARE that resulted in a segfault.

Also, there is another patch that may relate to bug 448 that deals with the same code:
Since I am not sure if that is needed or not, I will just note it for now, and this commit will only contain one patch:
commit 7194d455dbf9b4927057eacd443800d24ec40a19
Author: Erik de Castro Lopo <erikd@mega-nerd.com>
Date:   Tue Jun 28 18:22:12 2011 +1000

    src/strings.c : Clean up and refactor storage of SF_STR_SOFTWARE.

Because these are already in the next version of libsndfile I don't see a reason to note the patches
This commit is contained in:
mchinen 2012-05-24 08:45:22 +00:00
parent 9a621647be
commit 15fb587eb1

View File

@ -32,9 +32,8 @@ static void hexdump (void *data, int len) ;
int
psf_store_string (SF_PRIVATE *psf, int str_type, const char *str)
{ static char lsf_name [] = PACKAGE "-" VERSION ;
static char bracket_name [] = " (" PACKAGE "-" VERSION ")" ;
int k, str_len, len_remaining, str_flags ;
{ size_t len_remaining, str_len ;
int k, str_flags ;
if (str == NULL)
return SFE_STR_BAD_STRING ;
@ -97,27 +96,31 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str)
{ case SF_STR_SOFTWARE :
/* In write mode, want to append libsndfile-version to string. */
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ psf->strings [k].type = str_type ;
{ char new_str [128] ;
if (strstr (str, PACKAGE) == NULL)
{ /*
** If the supplied string does not already contain a
** libsndfile-X.Y.Z component, then add it.
*/
if (strlen (str) == 0)
snprintf (new_str, sizeof (new_str), "%s-%s", PACKAGE, VERSION) ;
else
snprintf (new_str, sizeof (new_str), "%s (%s-%s)", str, PACKAGE, VERSION) ;
}
else
snprintf (new_str, sizeof (new_str), "%s", str) ;
str = new_str ;
str_len = strlen (str) ;
psf->strings [k].type = str_type ;
psf->strings [k].str = psf->str_end ;
psf->strings [k].flags = str_flags ;
memcpy (psf->str_end, str, str_len + 1) ;
psf->str_end += str_len ;
/*
** If the supplied string does not already contain a
** libsndfile-X.Y.Z component, then add it.
*/
if (strstr (str, PACKAGE) == NULL && len_remaining > (int) (strlen (bracket_name) + str_len + 2))
{ if (strlen (str) == 0)
psf_strlcat (psf->str_end, sizeof (psf->str_storage), lsf_name) ;
else
psf_strlcat (psf->str_end, sizeof (psf->str_storage), bracket_name) ;
psf->str_end += strlen (psf->str_end) ;
} ;
/* Plus one to catch string terminator. */
psf->str_end += 1 ;
psf->str_end += str_len + 1 ;
break ;
} ;