Fix some potential buffer overflows
Verify the buffer size before accessing its content!
This commit is contained in:
parent
68380b2ec0
commit
350893fb27
@ -569,6 +569,14 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
unsigned int header = parser->header;
|
||||
const hw_ostc_layout_t *layout = parser->layout;
|
||||
|
||||
// Check the header length.
|
||||
if (version == 0x23 || version == 0x24) {
|
||||
if (size < header + 5) {
|
||||
ERROR (abstract->context, "Buffer overflow detected!");
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the sample rate.
|
||||
unsigned int samplerate = 0;
|
||||
if (version == 0x23 || version == 0x24)
|
||||
@ -595,6 +603,14 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
|
||||
// Check the header length.
|
||||
if (version == 0x23 || version == 0x24) {
|
||||
if (size < header + 5 + 3 * nconfig) {
|
||||
ERROR (abstract->context, "Buffer overflow detected!");
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the extended sample configuration.
|
||||
hw_ostc_sample_info_t info[MAXCONFIG] = {{0}};
|
||||
for (unsigned int i = 0; i < nconfig; ++i) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user