Compare commits
No commits in common. 'c9' and 'i8c-beta' have entirely different histories.
@ -1 +1 @@
|
||||
SOURCES/libsndfile-1.0.31.tar.bz2
|
||||
SOURCES/libsndfile-1.0.28.tar.gz
|
||||
|
@ -1 +1 @@
|
||||
f16a88e7223baef7c4497536dc1b55b56811debc SOURCES/libsndfile-1.0.31.tar.bz2
|
||||
85aa967e19f6b9bf975601d79669025e5f8bc77d SOURCES/libsndfile-1.0.28.tar.gz
|
||||
|
@ -0,0 +1,31 @@
|
||||
From df18323c622b54221ee7ace74b177cdcccc152d7 Mon Sep 17 00:00:00 2001
|
||||
From: "Brett T. Warden" <brett.t.warden@intel.com>
|
||||
Date: Tue, 28 Aug 2018 12:01:17 -0700
|
||||
Subject: [PATCH] Check MAX_CHANNELS in sndfile-deinterleave
|
||||
|
||||
Allocated buffer has space for only 16 channels. Verify that input file
|
||||
meets this limit.
|
||||
|
||||
Fixes #397
|
||||
---
|
||||
programs/sndfile-deinterleave.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/programs/sndfile-deinterleave.c b/programs/sndfile-deinterleave.c
|
||||
index 53660310..225b4d54 100644
|
||||
--- a/programs/sndfile-deinterleave.c
|
||||
+++ b/programs/sndfile-deinterleave.c
|
||||
@@ -89,6 +89,13 @@ main (int argc, char **argv)
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
+ if (sfinfo.channels > MAX_CHANNELS)
|
||||
+ { printf ("\nError : Input file '%s' has too many (%d) channels. Limit is %d.\n",
|
||||
+ argv [1], sfinfo.channels, MAX_CHANNELS) ;
|
||||
+ exit (1) ;
|
||||
+ } ;
|
||||
+
|
||||
+
|
||||
state.channels = sfinfo.channels ;
|
||||
sfinfo.channels = 1 ;
|
||||
|
@ -0,0 +1,88 @@
|
||||
From cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= <osmanx@problemloesungsmaschine.de>
|
||||
Date: Wed, 14 Jun 2017 12:25:40 +0200
|
||||
Subject: [PATCH] src/common.c: Fix heap buffer overflows when writing strings
|
||||
in binheader
|
||||
|
||||
Fixes the following problems:
|
||||
1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
|
||||
2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
|
||||
big switch statement by an amount (16 bytes) which is enough for all cases
|
||||
where only a single value gets added. Cases 's', 'S', 'p' however
|
||||
additionally write an arbitrary length block of data and again enlarge the
|
||||
buffer to the required amount. However, the required space calculation does
|
||||
not take into account the size of the length field which gets output before
|
||||
the data.
|
||||
3. Buffer size requirement calculation in case 'S' does not account for the
|
||||
padding byte ("size += (size & 1) ;" happens after the calculation which
|
||||
uses "size").
|
||||
4. Case 'S' can overrun the header buffer by 1 byte when no padding is
|
||||
involved
|
||||
("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
|
||||
the buffer is only guaranteed to have "size" space available).
|
||||
5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
|
||||
beyond the space which is guaranteed to be allocated in the header buffer.
|
||||
6. Case 's' can overrun the provided source string by 1 byte if padding is
|
||||
involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
|
||||
where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
|
||||
plus optionally another 1 which is padding and not guaranteed to be
|
||||
readable via the source string pointer).
|
||||
|
||||
Closes: https://github.com/erikd/libsndfile/issues/292
|
||||
---
|
||||
src/common.c | 15 +++++++--------
|
||||
1 file changed, 7 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/common.c b/src/common.c
|
||||
index 1a6204ca..6b2a2ee9 100644
|
||||
--- a/src/common.c
|
||||
+++ b/src/common.c
|
||||
@@ -681,16 +681,16 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
/* Write a C string (guaranteed to have a zero terminator). */
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) + 1 ;
|
||||
- size += (size & 1) ;
|
||||
|
||||
- if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
|
||||
+ if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
|
||||
return count ;
|
||||
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
- header_put_be_int (psf, size) ;
|
||||
+ header_put_be_int (psf, size + (size & 1)) ;
|
||||
else
|
||||
- header_put_le_int (psf, size) ;
|
||||
+ header_put_le_int (psf, size + (size & 1)) ;
|
||||
memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
|
||||
+ size += (size & 1) ;
|
||||
psf->header.indx += size ;
|
||||
psf->header.ptr [psf->header.indx - 1] = 0 ;
|
||||
count += 4 + size ;
|
||||
@@ -703,16 +703,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
*/
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) ;
|
||||
- if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
|
||||
return count ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
header_put_be_int (psf, size) ;
|
||||
else
|
||||
header_put_le_int (psf, size) ;
|
||||
- memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;
|
||||
+ memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
|
||||
size += (size & 1) ;
|
||||
psf->header.indx += size ;
|
||||
- psf->header.ptr [psf->header.indx] = 0 ;
|
||||
count += 4 + size ;
|
||||
break ;
|
||||
|
||||
@@ -724,7 +723,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
|
||||
size = (size & 1) ? size : size + 1 ;
|
||||
size = (size > 254) ? 254 : size ;
|
||||
|
||||
- if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
|
||||
return count ;
|
||||
|
||||
header_put_byte (psf, size) ;
|
@ -0,0 +1,91 @@
|
||||
From 585cc28a93be27d6938f276af0011401b9f7c0ca Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Lefeuvre <hle@owl.eu.com>
|
||||
Date: Mon, 24 Dec 2018 06:43:48 +0100
|
||||
Subject: [PATCH] a/ulaw: fix multiple buffer overflows (#432)
|
||||
|
||||
i2ulaw_array() and i2alaw_array() fail to handle ptr [count] = INT_MIN
|
||||
properly, leading to buffer underflow. INT_MIN is a special value
|
||||
since - INT_MIN cannot be represented as int.
|
||||
|
||||
In this case round - INT_MIN to INT_MAX and proceed as usual.
|
||||
|
||||
f2ulaw_array() and f2alaw_array() fail to handle ptr [count] = NaN
|
||||
properly, leading to null pointer dereference.
|
||||
|
||||
In this case, arbitrarily set the buffer value to 0.
|
||||
|
||||
This commit fixes #429 (CVE-2018-19661 and CVE-2018-19662) and
|
||||
fixes #344 (CVE-2017-17456 and CVE-2017-17457).
|
||||
---
|
||||
src/alaw.c | 9 +++++++--
|
||||
src/ulaw.c | 9 +++++++--
|
||||
2 files changed, 14 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/alaw.c b/src/alaw.c
|
||||
index 063fd1a2..4220224c 100644
|
||||
--- a/src/alaw.c
|
||||
+++ b/src/alaw.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <math.h>
|
||||
+#include <limits.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "common.h"
|
||||
@@ -326,7 +327,9 @@ s2alaw_array (const short *ptr, int count, unsigned char *buffer)
|
||||
static inline void
|
||||
i2alaw_array (const int *ptr, int count, unsigned char *buffer)
|
||||
{ while (--count >= 0)
|
||||
- { if (ptr [count] >= 0)
|
||||
+ { if (ptr [count] == INT_MIN)
|
||||
+ buffer [count] = alaw_encode [INT_MAX >> (16 + 4)] ;
|
||||
+ else if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [ptr [count] >> (16 + 4)] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [- ptr [count] >> (16 + 4)] ;
|
||||
@@ -346,7 +349,9 @@ f2alaw_array (const float *ptr, int count, unsigned char *buffer, float normfact
|
||||
static inline void
|
||||
d2alaw_array (const double *ptr, int count, unsigned char *buffer, double normfact)
|
||||
{ while (--count >= 0)
|
||||
- { if (ptr [count] >= 0)
|
||||
+ { if (!isfinite (ptr [count]))
|
||||
+ buffer [count] = 0 ;
|
||||
+ else if (ptr [count] >= 0)
|
||||
buffer [count] = alaw_encode [lrint (normfact * ptr [count])] ;
|
||||
else
|
||||
buffer [count] = 0x7F & alaw_encode [- lrint (normfact * ptr [count])] ;
|
||||
diff --git a/src/ulaw.c b/src/ulaw.c
|
||||
index e50b4cb5..b6070ade 100644
|
||||
--- a/src/ulaw.c
|
||||
+++ b/src/ulaw.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <math.h>
|
||||
+#include <limits.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
#include "common.h"
|
||||
@@ -827,7 +828,9 @@ s2ulaw_array (const short *ptr, int count, unsigned char *buffer)
|
||||
static inline void
|
||||
i2ulaw_array (const int *ptr, int count, unsigned char *buffer)
|
||||
{ while (--count >= 0)
|
||||
- { if (ptr [count] >= 0)
|
||||
+ { if (ptr [count] == INT_MIN)
|
||||
+ buffer [count] = ulaw_encode [INT_MAX >> (16 + 2)] ;
|
||||
+ else if (ptr [count] >= 0)
|
||||
buffer [count] = ulaw_encode [ptr [count] >> (16 + 2)] ;
|
||||
else
|
||||
buffer [count] = 0x7F & ulaw_encode [-ptr [count] >> (16 + 2)] ;
|
||||
@@ -847,7 +850,9 @@ f2ulaw_array (const float *ptr, int count, unsigned char *buffer, float normfact
|
||||
static inline void
|
||||
d2ulaw_array (const double *ptr, int count, unsigned char *buffer, double normfact)
|
||||
{ while (--count >= 0)
|
||||
- { if (ptr [count] >= 0)
|
||||
+ { if (!isfinite (ptr [count]))
|
||||
+ buffer [count] = 0 ;
|
||||
+ else if (ptr [count] >= 0)
|
||||
buffer [count] = ulaw_encode [lrint (normfact * ptr [count])] ;
|
||||
else
|
||||
buffer [count] = 0x7F & ulaw_encode [- lrint (normfact * ptr [count])] ;
|
@ -0,0 +1,11 @@
|
||||
diff -up libsndfile-1.0.28/src/sndfile.c.fixfree libsndfile-1.0.28/src/sndfile.c
|
||||
--- libsndfile-1.0.28/src/sndfile.c.fixfree 2018-10-15 14:24:26.521941046 +0200
|
||||
+++ libsndfile-1.0.28/src/sndfile.c 2018-10-15 14:24:26.534940869 +0200
|
||||
@@ -339,6 +339,7 @@ sf_open (const char *path, int mode, SF_
|
||||
|
||||
if (copy_filename (psf, path) != 0)
|
||||
{ sf_errno = psf->error ;
|
||||
+ free(psf);
|
||||
return NULL ;
|
||||
} ;
|
||||
|
@ -0,0 +1,64 @@
|
||||
From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
|
||||
From: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
Date: Wed, 12 Apr 2017 19:45:30 +1000
|
||||
Subject: [PATCH] FLAC: Fix a buffer read overrun
|
||||
|
||||
Buffer read overrun occurs when reading a FLAC file that switches
|
||||
from 2 channels to one channel mid-stream. Only option is to
|
||||
abort the read.
|
||||
|
||||
Closes: https://github.com/erikd/libsndfile/issues/230
|
||||
---
|
||||
src/common.h | 1 +
|
||||
src/flac.c | 13 +++++++++++++
|
||||
src/sndfile.c | 1 +
|
||||
3 files changed, 15 insertions(+)
|
||||
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index 0bd810c3..e2669b6a 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -725,6 +725,7 @@ enum
|
||||
SFE_FLAC_INIT_DECODER,
|
||||
SFE_FLAC_LOST_SYNC,
|
||||
SFE_FLAC_BAD_SAMPLE_RATE,
|
||||
+ SFE_FLAC_CHANNEL_COUNT_CHANGED,
|
||||
SFE_FLAC_UNKOWN_ERROR,
|
||||
|
||||
SFE_WVE_NOT_WVE,
|
||||
diff --git a/src/flac.c b/src/flac.c
|
||||
index 84de0e26..986a7b8f 100644
|
||||
--- a/src/flac.c
|
||||
+++ b/src/flac.c
|
||||
@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
|
||||
|
||||
switch (metadata->type)
|
||||
{ case FLAC__METADATA_TYPE_STREAMINFO :
|
||||
+ if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
|
||||
+ { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
|
||||
+ "Nothing to be but to error out.\n" ,
|
||||
+ psf->sf.channels, metadata->data.stream_info.channels) ;
|
||||
+ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
|
||||
+ return ;
|
||||
+ } ;
|
||||
+
|
||||
+ if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
|
||||
+ { psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
|
||||
+ "Carrying on as if nothing happened.",
|
||||
+ psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
|
||||
+ } ;
|
||||
psf->sf.channels = metadata->data.stream_info.channels ;
|
||||
psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
|
||||
psf->sf.frames = metadata->data.stream_info.total_samples ;
|
||||
diff --git a/src/sndfile.c b/src/sndfile.c
|
||||
index 41875610..e2a87be8 100644
|
||||
--- a/src/sndfile.c
|
||||
+++ b/src/sndfile.c
|
||||
@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
|
||||
{ SFE_FLAC_INIT_DECODER , "Error : problem with initialization of the flac decoder." },
|
||||
{ SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." },
|
||||
{ SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
|
||||
+ { SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
|
||||
{ SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." },
|
||||
|
||||
{ SFE_WVE_NOT_WVE , "Error : not a WVE file." },
|
@ -0,0 +1,114 @@
|
||||
diff -up libsndfile-1.0.28/src/common.c.vafix libsndfile-1.0.28/src/common.c
|
||||
--- libsndfile-1.0.28/src/common.c.vafix 2018-10-15 14:31:59.805758665 +0200
|
||||
+++ libsndfile-1.0.28/src/common.c 2018-10-15 14:34:48.978445310 +0200
|
||||
@@ -561,7 +561,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
while ((c = *format++))
|
||||
{
|
||||
if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
switch (c)
|
||||
{ case ' ' : /* Do nothing. Just used to space out format string. */
|
||||
@@ -677,7 +680,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = strlen (strptr) + 1 ;
|
||||
|
||||
if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
header_put_be_int (psf, size + (size & 1)) ;
|
||||
@@ -698,7 +704,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
strptr = va_arg (argptr, char *) ;
|
||||
size = strlen (strptr) ;
|
||||
if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
header_put_be_int (psf, size) ;
|
||||
else
|
||||
@@ -718,7 +727,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = (size > 254) ? 254 : size ;
|
||||
|
||||
if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
header_put_byte (psf, size) ;
|
||||
memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
|
||||
@@ -731,7 +743,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = va_arg (argptr, size_t) ;
|
||||
|
||||
if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
memcpy (&(psf->header.ptr [psf->header.indx]), bindata, size) ;
|
||||
psf->header.indx += size ;
|
||||
@@ -742,7 +757,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = va_arg (argptr, size_t) ;
|
||||
|
||||
if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
count += size ;
|
||||
while (size)
|
||||
@@ -763,7 +781,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = va_arg (argptr, size_t) ;
|
||||
|
||||
if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
psf->header.indx += size ;
|
||||
count += size ;
|
||||
@@ -773,7 +794,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
|
||||
size = va_arg (argptr, size_t) ;
|
||||
|
||||
if ((sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, size))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
psf->header.indx = size ;
|
||||
break ;
|
||||
@@ -960,7 +984,10 @@ psf_binheader_readf (SF_PRIVATE *psf, ch
|
||||
while ((c = *format++))
|
||||
{
|
||||
if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
return count ;
|
||||
+ } ;
|
||||
|
||||
switch (c)
|
||||
{ case 'e' : /* All conversions are now from LE to host. */
|
||||
@@ -1087,7 +1114,10 @@ psf_binheader_readf (SF_PRIVATE *psf, ch
|
||||
memset (charptr, 0, count) ;
|
||||
|
||||
if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
|
||||
- return 0 ;
|
||||
+ {
|
||||
+ va_end (argptr) ;
|
||||
+ return count ;
|
||||
+ } ;
|
||||
|
||||
byte_count += header_gets (psf, charptr, count) ;
|
||||
break ;
|
@ -0,0 +1,25 @@
|
||||
From f833c53cb596e9e1792949f762e0b33661822748 Mon Sep 17 00:00:00 2001
|
||||
From: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
Date: Tue, 23 May 2017 20:15:24 +1000
|
||||
Subject: [PATCH] src/aiff.c: Fix a buffer read overflow
|
||||
|
||||
Secunia Advisory SA76717.
|
||||
|
||||
Found by: Laurent Delosieres, Secunia Research at Flexera Software
|
||||
---
|
||||
src/aiff.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/aiff.c b/src/aiff.c
|
||||
index 5b5f9f53..45864b76 100644
|
||||
--- a/src/aiff.c
|
||||
+++ b/src/aiff.c
|
||||
@@ -1759,7 +1759,7 @@ aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword)
|
||||
psf_binheader_readf (psf, "j", dword - bytesread) ;
|
||||
|
||||
if (map_info->channel_map != NULL)
|
||||
- { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ;
|
||||
+ { size_t chanmap_size = SF_MIN (psf->sf.channels, layout_tag & 0xffff) * sizeof (psf->channel_map [0]) ;
|
||||
|
||||
free (psf->channel_map) ;
|
||||
|
@ -1,397 +0,0 @@
|
||||
From 4755f5bd7854611d92ad0f1295587b439f9950ba Mon Sep 17 00:00:00 2001
|
||||
From: Arthur Taylor <art@ified.ca>
|
||||
Date: Fri, 15 Nov 2024 19:46:53 -0800
|
||||
Subject: [PATCH] src/ogg: better error checking for vorbis. Fixes #1035
|
||||
|
||||
---
|
||||
src/ogg.c | 12 ++--
|
||||
src/ogg_opus.c | 17 +++--
|
||||
src/ogg_vorbis.c | 170 ++++++++++++++++++++++++++---------------------
|
||||
3 files changed, 114 insertions(+), 85 deletions(-)
|
||||
|
||||
diff --git a/src/ogg.c b/src/ogg.c
|
||||
index 529941af..e2d679d4 100644
|
||||
--- a/src/ogg.c
|
||||
+++ b/src/ogg.c
|
||||
@@ -211,12 +211,16 @@ ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
|
||||
|
||||
int
|
||||
ogg_write_page (SF_PRIVATE *psf, ogg_page *page)
|
||||
-{ int bytes ;
|
||||
+{ int n ;
|
||||
|
||||
- bytes = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
- bytes += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
+ n = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
+ if (n == page->header_len)
|
||||
+ n += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
|
||||
- return bytes == page->header_len + page->body_len ;
|
||||
+ if (n != page->body_len + page->header_len)
|
||||
+ return -1 ;
|
||||
+
|
||||
+ return n ;
|
||||
} /* ogg_write_page */
|
||||
|
||||
sf_count_t
|
||||
diff --git a/src/ogg_opus.c b/src/ogg_opus.c
|
||||
index 511653ec..e01224b9 100644
|
||||
--- a/src/ogg_opus.c
|
||||
+++ b/src/ogg_opus.c
|
||||
@@ -827,15 +827,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
|
||||
/* The first page MUST only contain the header, so flush it out now */
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
- for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
- { if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
+ while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
+ { nn = ogg_write_page (psf, &odata->opage) ;
|
||||
+ if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write header!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
- }
|
||||
+ } ;
|
||||
|
||||
/*
|
||||
** Metadata Tags (manditory)
|
||||
@@ -850,15 +851,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ;
|
||||
op.packetno = 2 ;
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
- for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
- { if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
+ while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
+ { nn = ogg_write_page (psf, &odata->opage) ;
|
||||
+ if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write comments!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
- }
|
||||
+ } ;
|
||||
|
||||
return 0 ;
|
||||
} /* ogg_opus_write_header */
|
||||
@@ -1126,7 +1126,8 @@ ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus)
|
||||
*/
|
||||
oopus->u.encode.last_segments -= odata->opage.header [26] ;
|
||||
oopus->pg_pos = oopus->pkt_pos ;
|
||||
- ogg_write_page (psf, &odata->opage) ;
|
||||
+ if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
+ return -1 ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
diff --git a/src/ogg_vorbis.c b/src/ogg_vorbis.c
|
||||
index add12396..fae252ca 100644
|
||||
--- a/src/ogg_vorbis.c
|
||||
+++ b/src/ogg_vorbis.c
|
||||
@@ -78,26 +78,6 @@ typedef struct
|
||||
|
||||
#include "ogg.h"
|
||||
|
||||
-typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
|
||||
-
|
||||
-static int vorbis_read_header (SF_PRIVATE *psf) ;
|
||||
-static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
-static int vorbis_close (SF_PRIVATE *psf) ;
|
||||
-static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||
-static int vorbis_byterate (SF_PRIVATE *psf) ;
|
||||
-static sf_count_t vorbis_calculate_page_duration (SF_PRIVATE *psf) ;
|
||||
-static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
-static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
-static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
|
||||
-static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
|
||||
-
|
||||
typedef struct
|
||||
{ int id ;
|
||||
const char *name ;
|
||||
@@ -145,6 +123,43 @@ typedef struct
|
||||
sf_count_t last_page ;
|
||||
} VORBIS_PRIVATE ;
|
||||
|
||||
+typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
|
||||
+
|
||||
+static int vorbis_read_header (SF_PRIVATE *psf) ;
|
||||
+static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
+static int vorbis_close (SF_PRIVATE *psf) ;
|
||||
+static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||
+static int vorbis_byterate (SF_PRIVATE *psf) ;
|
||||
+static sf_count_t vorbis_calculate_page_duration (SF_PRIVATE *psf) ;
|
||||
+static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
+static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
+static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
|
||||
+static int vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) ;
|
||||
+static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
|
||||
+static void vorbis_log_error (SF_PRIVATE *psf, int error) ;
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+vorbis_log_error(SF_PRIVATE *psf, int error) {
|
||||
+ switch (error)
|
||||
+ { case 0: return;
|
||||
+ case OV_EIMPL: psf->error = SFE_UNIMPLEMENTED ; break ;
|
||||
+ case OV_ENOTVORBIS: psf->error = SFE_MALFORMED_FILE ; break ;
|
||||
+ case OV_EBADHEADER: psf->error = SFE_MALFORMED_FILE ; break ;
|
||||
+ case OV_EVERSION: psf->error = SFE_UNSUPPORTED_ENCODING ; break ;
|
||||
+ case OV_EFAULT:
|
||||
+ case OV_EINVAL:
|
||||
+ default: psf->error = SFE_INTERNAL ;
|
||||
+ } ;
|
||||
+} ;
|
||||
+
|
||||
static int
|
||||
vorbis_read_header (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
@@ -380,7 +397,6 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
{ ogg_packet header ;
|
||||
ogg_packet header_comm ;
|
||||
ogg_packet header_code ;
|
||||
- int result ;
|
||||
|
||||
vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ;
|
||||
ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */
|
||||
@@ -390,9 +406,9 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||
/* This ensures the actual
|
||||
* audio data will start on a new page, as per spec
|
||||
*/
|
||||
- while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0)
|
||||
- { ogg_write_page (psf, &odata->opage) ;
|
||||
- } ;
|
||||
+ while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
+ if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
+ return -1 ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
@@ -402,6 +418,7 @@ static int
|
||||
vorbis_close (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE* odata = psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = psf->codec_data ;
|
||||
+ int ret = 0 ;
|
||||
|
||||
if (odata == NULL || vdata == NULL)
|
||||
return 0 ;
|
||||
@@ -412,34 +429,14 @@ vorbis_close (SF_PRIVATE *psf)
|
||||
if (psf->file.mode == SFM_WRITE)
|
||||
{
|
||||
if (psf->write_current <= 0)
|
||||
- vorbis_write_header (psf, 0) ;
|
||||
-
|
||||
- vorbis_analysis_wrote (&vdata->vdsp, 0) ;
|
||||
- while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
- {
|
||||
+ ret = vorbis_write_header (psf, 0) ;
|
||||
|
||||
- /* analysis, assume we want to use bitrate management */
|
||||
- vorbis_analysis (&vdata->vblock, NULL) ;
|
||||
- vorbis_bitrate_addblock (&vdata->vblock) ;
|
||||
-
|
||||
- while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
|
||||
- { /* weld the packet into the bitstream */
|
||||
- ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
|
||||
-
|
||||
- /* write out pages (if any) */
|
||||
- while (!odata->eos)
|
||||
- { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
- if (result == 0) break ;
|
||||
- ogg_write_page (psf, &odata->opage) ;
|
||||
-
|
||||
- /* this could be set above, but for illustrative purposes, I do
|
||||
- it here (to show that vorbis does know where the stream ends) */
|
||||
-
|
||||
- if (ogg_page_eos (&odata->opage)) odata->eos = 1 ;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ if (ret == 0)
|
||||
+ { /* A write of zero samples tells Vorbis the stream is done and to
|
||||
+ flush. */
|
||||
+ ret = vorbis_write_samples (psf, odata, vdata, 0) ;
|
||||
+ } ;
|
||||
+ } ;
|
||||
|
||||
/* ogg_page and ogg_packet structs always point to storage in
|
||||
libvorbis. They are never freed or manipulated directly */
|
||||
@@ -449,7 +446,7 @@ vorbis_close (SF_PRIVATE *psf)
|
||||
vorbis_comment_clear (&vdata->vcomment) ;
|
||||
vorbis_info_clear (&vdata->vinfo) ;
|
||||
|
||||
- return 0 ;
|
||||
+ return ret ;
|
||||
} /* vorbis_close */
|
||||
|
||||
int
|
||||
@@ -688,33 +685,40 @@ vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
-static void
|
||||
+static int
|
||||
vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
|
||||
-{
|
||||
- vorbis_analysis_wrote (&vdata->vdsp, in_frames) ;
|
||||
+{ int ret ;
|
||||
+
|
||||
+ if ((ret = vorbis_analysis_wrote (&vdata->vdsp, in_frames)) != 0)
|
||||
+ return ret ;
|
||||
|
||||
/*
|
||||
** Vorbis does some data preanalysis, then divvies up blocks for
|
||||
** more involved (potentially parallel) processing. Get a single
|
||||
** block for encoding now.
|
||||
*/
|
||||
- while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
+ while ((ret = vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock)) == 1)
|
||||
{
|
||||
/* analysis, assume we want to use bitrate management */
|
||||
- vorbis_analysis (&vdata->vblock, NULL) ;
|
||||
- vorbis_bitrate_addblock (&vdata->vblock) ;
|
||||
+ if ((ret = vorbis_analysis (&vdata->vblock, NULL)) != 0)
|
||||
+ return ret ;
|
||||
+ if ((ret = vorbis_bitrate_addblock (&vdata->vblock)) != 0)
|
||||
+ return ret ;
|
||||
|
||||
- while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
|
||||
+ while ((ret = vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) == 1)
|
||||
{
|
||||
/* weld the packet into the bitstream */
|
||||
- ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
|
||||
+ if ((ret = ogg_stream_packetin (&odata->ostream, &odata->opacket)) != 0)
|
||||
+ return ret ;
|
||||
|
||||
/* write out pages (if any) */
|
||||
while (!odata->eos)
|
||||
- { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
- if (result == 0)
|
||||
+ { ret = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
+ if (ret == 0)
|
||||
break ;
|
||||
- ogg_write_page (psf, &odata->opage) ;
|
||||
+
|
||||
+ if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
+ return -1 ;
|
||||
|
||||
/* This could be set above, but for illustrative purposes, I do
|
||||
** it here (to show that vorbis does know where the stream ends) */
|
||||
@@ -726,9 +726,15 @@
|
||||
odata->eos = 1 ;
|
||||
} ;
|
||||
} ;
|
||||
+ if (ret != 0)
|
||||
+ return ret ;
|
||||
} ;
|
||||
+ if (ret != 0)
|
||||
+ return ret ;
|
||||
|
||||
vdata->loc += in_frames ;
|
||||
+
|
||||
+ return 0 ;
|
||||
} /* vorbis_write_data */
|
||||
|
||||
|
||||
@@ -735,7 +740,7 @@
|
||||
static sf_count_t
|
||||
vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
||||
{
|
||||
- int i, m, j = 0 ;
|
||||
+ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
@@ -740,14 +750,17 @@ vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
||||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 32767.0f ;
|
||||
|
||||
- vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
+ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
+ { vorbis_log_error (psf, ret) ;
|
||||
+ return 0 ;
|
||||
+ } ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_s */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
||||
-{ int i, m, j = 0 ;
|
||||
+{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
@@ -756,14 +769,17 @@ vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
||||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ;
|
||||
|
||||
- vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
+ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
+ { vorbis_log_error (psf, ret) ;
|
||||
+ return 0 ;
|
||||
+ } ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_i */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
||||
-{ int i, m, j = 0 ;
|
||||
+{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
@@ -772,14 +788,17 @@ vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
||||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = ptr [j++] ;
|
||||
|
||||
- vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
+ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
+ { vorbis_log_error (psf, ret) ;
|
||||
+ return 0 ;
|
||||
+ } ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_f */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
||||
-{ int i, m, j = 0 ;
|
||||
+{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
@@ -788,7 +807,10 @@ vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
||||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) ptr [j++] ;
|
||||
|
||||
- vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
+ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
+ { vorbis_log_error (psf, ret) ;
|
||||
+ return 0 ;
|
||||
+ } ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_d */
|
||||
--
|
||||
2.47.0
|
||||
|
@ -0,0 +1,37 @@
|
||||
--- libsndfile-1.0.28/src/rf64.c 2017-04-02 09:43:22.000000000 +0200
|
||||
+++ libsndfile-1.0.27/src/rf64.c 2016-04-01 23:08:53.000000000 +0200
|
||||
@@ -735,25 +734,27 @@ rf64_write_header (SF_PRIVATE *psf, int
|
||||
|
||||
#endif
|
||||
|
||||
- pad_size = psf->dataoffset - 16 - psf->header.indx ;
|
||||
- if (pad_size >= 0)
|
||||
- psf_binheader_writef (psf, "m4z", PAD_MARKER, pad_size, make_size_t (pad_size)) ;
|
||||
+ if (psf->header.indx + 8 < psf->dataoffset)
|
||||
+ { /* Add PAD data if necessary. */
|
||||
+ int k = psf->dataoffset - 16 - psf->header.indx ;
|
||||
+ psf_binheader_writef (psf, "m4z", PAD_MARKER, k, make_size_t (k)) ;
|
||||
+ } ;
|
||||
|
||||
if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES))
|
||||
psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;
|
||||
else
|
||||
psf_binheader_writef (psf, "m4", data_MARKER, 0xffffffff) ;
|
||||
|
||||
- psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ;
|
||||
+ psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
|
||||
- if (has_data && psf->dataoffset != psf->header.indx)
|
||||
- { psf_log_printf (psf, "Oooops : has_data && psf->dataoffset != psf->header.indx\n") ;
|
||||
+ if (has_data && psf->dataoffset != psf->header.indx)
|
||||
+ { psf_log_printf (psf, "Oooops : has_data && psf->dataoffset != psf->header.indx\n") ;
|
||||
return psf->error = SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
- psf->dataoffset = psf->header.indx ;
|
||||
+ psf->dataoffset = psf->header.indx ;
|
||||
|
||||
if (NOT (has_data))
|
||||
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
|
Loading…
Reference in new issue