|
Lines 1-6
Link Here
|
| 1 |
--- oggenc/audio.c.orig 2010-03-24 08:27:14 UTC |
1 |
--- oggenc/audio.c.orig 2010-03-24 08:27:14 UTC |
| 2 |
+++ oggenc/audio.c |
2 |
+++ oggenc/audio.c |
| 3 |
@@ -245,8 +245,8 @@ static int aiff_permute_matrix[6][6] = |
3 |
@@ -13,6 +13,7 @@ |
|
|
4 |
#include <config.h> |
| 5 |
#endif |
| 6 |
|
| 7 |
+#include <limits.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include <stdio.h> |
| 10 |
#include <string.h> |
| 11 |
@@ -245,12 +246,13 @@ static int aiff_permute_matrix[6][6] = |
| 4 |
int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen) |
12 |
int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen) |
| 5 |
{ |
13 |
{ |
| 6 |
int aifc; /* AIFC or AIFF? */ |
14 |
int aifc; /* AIFC or AIFF? */ |
|
Lines 11-17
Link Here
|
| 11 |
unsigned char buf2[8]; |
19 |
unsigned char buf2[8]; |
| 12 |
aiff_fmt format; |
20 |
aiff_fmt format; |
| 13 |
aifffile *aiff = malloc(sizeof(aifffile)); |
21 |
aifffile *aiff = malloc(sizeof(aifffile)); |
| 14 |
@@ -269,9 +269,9 @@ int aiff_open(FILE *in, oe_enc_opt *opt, |
22 |
int i; |
|
|
23 |
+ long channels; |
| 24 |
|
| 25 |
if(buf[11]=='C') |
| 26 |
aifc=1; |
| 27 |
@@ -269,19 +271,25 @@ int aiff_open(FILE *in, oe_enc_opt *opt, |
| 15 |
return 0; /* Weird common chunk */ |
28 |
return 0; /* Weird common chunk */ |
| 16 |
} |
29 |
} |
| 17 |
|
30 |
|
|
Lines 24-26
Link Here
|
| 24 |
{ |
37 |
{ |
| 25 |
fprintf(stderr, _("Warning: Unexpected EOF in reading AIFF header\n")); |
38 |
fprintf(stderr, _("Warning: Unexpected EOF in reading AIFF header\n")); |
| 26 |
return 0; |
39 |
return 0; |
|
|
40 |
} |
| 41 |
|
| 42 |
- format.channels = READ_U16_BE(buffer); |
| 43 |
+ format.channels = channels = READ_U16_BE(buffer); |
| 44 |
format.totalframes = READ_U32_BE(buffer+2); |
| 45 |
format.samplesize = READ_U16_BE(buffer+6); |
| 46 |
format.rate = (int)read_IEEE80(buffer+8); |
| 47 |
|
| 48 |
+ if(channels <= 0L || SHRT_MAX < channels) |
| 49 |
+ { |
| 50 |
+ fprintf(stderr, _("Warning: Unsupported count of channels in AIFF header\n")); |
| 51 |
+ return 0; |
| 52 |
+ } |
| 53 |
+ |
| 54 |
aiff->bigendian = 1; |
| 55 |
|
| 56 |
if(aifc) |
| 57 |
@@ -412,6 +420,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, |
| 58 |
wav_fmt format; |
| 59 |
wavfile *wav = malloc(sizeof(wavfile)); |
| 60 |
int i; |
| 61 |
+ long channels; |
| 62 |
|
| 63 |
/* Ok. At this point, we know we have a WAV file. Now we have to detect |
| 64 |
* whether we support the subtype, and we have to find the actual data |
| 65 |
@@ -449,12 +458,18 @@ int wav_open(FILE *in, oe_enc_opt *opt, |
| 66 |
} |
| 67 |
|
| 68 |
format.format = READ_U16_LE(buf); |
| 69 |
- format.channels = READ_U16_LE(buf+2); |
| 70 |
+ format.channels = channels = READ_U16_LE(buf+2); |
| 71 |
format.samplerate = READ_U32_LE(buf+4); |
| 72 |
format.bytespersec = READ_U32_LE(buf+8); |
| 73 |
format.align = READ_U16_LE(buf+12); |
| 74 |
format.samplesize = READ_U16_LE(buf+14); |
| 75 |
|
| 76 |
+ if(channels <= 0L || SHRT_MAX < channels) |
| 77 |
+ { |
| 78 |
+ fprintf(stderr, _("Warning: Unsupported count of channels in WAV header\n")); |
| 79 |
+ return 0; |
| 80 |
+ } |
| 81 |
+ |
| 82 |
if(format.format == -2) /* WAVE_FORMAT_EXTENSIBLE */ |
| 83 |
{ |
| 84 |
if(len<40) |