examples/c/decode/file/main.c : Add extra error handling.
Michele Spagnuolo provided a file that initially had frames with two channels but then had a frame with a single channel. This example program only supports exactly two channels and previously had insufficient validation. Closes: https://sourceforge.net/p/flac/bugs/418/ Reported-by: Michele Spagnuolo, Google Security Team <mikispag@google.com>
This commit is contained in:
parent
5b3033a2b3
commit
93846ee223
@ -125,6 +125,18 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
|
||||
fprintf(stderr, "ERROR: this example only supports 16bit stereo streams\n");
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
if(frame->header.channels != 2) {
|
||||
fprintf(stderr, "ERROR: This frame contains %d channels (should be 2)\n", frame->header.channels);
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
if(buffer [0] == NULL) {
|
||||
fprintf(stderr, "ERROR: buffer [0] is NULL\n");
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
if(buffer [1] == NULL) {
|
||||
fprintf(stderr, "ERROR: buffer [1] is NULL\n");
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
|
||||
/* write WAVE header before we write the first frame */
|
||||
if(frame->header.number.sample_number == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user