summaryrefslogtreecommitdiff
path: root/apps/codecs/libwavpack/wputils.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwavpack/wputils.c')
-rw-r--r--apps/codecs/libwavpack/wputils.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/codecs/libwavpack/wputils.c b/apps/codecs/libwavpack/wputils.c
index 7a6cc44ad4..7fabc7ab34 100644
--- a/apps/codecs/libwavpack/wputils.c
+++ b/apps/codecs/libwavpack/wputils.c
@@ -69,9 +69,10 @@ WavpackContext *WavpackOpenFileInput (read_stream infile, char *error)
69 return NULL; 69 return NULL;
70 } 70 }
71 71
72 if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) { 72 if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < MIN_STREAM_VERS ||
73 strcpy_loc (error, "invalid WavPack file!"); 73 wps->wphdr.version > MAX_STREAM_VERS) {
74 return NULL; 74 strcpy_loc (error, "invalid WavPack file!");
75 return NULL;
75 } 76 }
76 77
77 if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1) 78 if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1)
@@ -170,7 +171,7 @@ uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t sa
170 if (bcount == (uint32_t) -1) 171 if (bcount == (uint32_t) -1)
171 break; 172 break;
172 173
173 if (wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) { 174 if (wps->wphdr.version < MIN_STREAM_VERS || wps->wphdr.version > MAX_STREAM_VERS) {
174 strcpy_loc (wpc->error_message, "invalid WavPack file!"); 175 strcpy_loc (wpc->error_message, "invalid WavPack file!");
175 break; 176 break;
176 } 177 }
@@ -341,7 +342,8 @@ static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr)
341 sp = buffer; 342 sp = buffer;
342 343
343 if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' && 344 if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' &&
344 !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 && sp [4] >= 2 && sp [4] <= 0xf) { 345 !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 &&
346 sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) {
345 memcpy (wphdr, buffer, sizeof (*wphdr)); 347 memcpy (wphdr, buffer, sizeof (*wphdr));
346 little_endian_to_native (wphdr, WavpackHeaderFormat); 348 little_endian_to_native (wphdr, WavpackHeaderFormat);
347 return bytes_skipped; 349 return bytes_skipped;
@@ -452,7 +454,7 @@ int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_
452 memcpy (wps->wphdr.ckID, "wvpk", 4); 454 memcpy (wps->wphdr.ckID, "wvpk", 4);
453 wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; 455 wps->wphdr.ckSize = sizeof (WavpackHeader) - 8;
454 wps->wphdr.total_samples = wpc->total_samples; 456 wps->wphdr.total_samples = wpc->total_samples;
455 wps->wphdr.version = 0x403; 457 wps->wphdr.version = CUR_STREAM_VERS;
456 wps->wphdr.flags = flags; 458 wps->wphdr.flags = flags;
457 459
458 pack_init (wpc); 460 pack_init (wpc);