typefind: Fix out-of-bound read in PNM typefinder

This commit is contained in:
Edward Hervey 2017-11-02 15:14:49 +01:00 committed by Edward Hervey
parent 24a5a03d27
commit a23d4d1c1f

View file

@ -4148,15 +4148,24 @@ pnm_type_find (GstTypeFind * tf, gpointer ununsed)
/* need to skip any comment lines first */ /* need to skip any comment lines first */
data_scan_ctx_advance (tf, &c, 3); data_scan_ctx_advance (tf, &c, 3);
if (!data_scan_ctx_ensure_data (tf, &c, 1))
return;
while (c.data[0] == '#') { /* we know there's still data left */ while (c.data[0] == '#') { /* we know there's still data left */
data_scan_ctx_advance (tf, &c, 1); data_scan_ctx_advance (tf, &c, 1);
while (c.data[0] != '\n' && c.data[0] != '\r') { if (!data_scan_ctx_ensure_data (tf, &c, 1))
if (!data_scan_ctx_ensure_data (tf, &c, 4))
return; return;
while (c.data[0] != '\n' && c.data[0] != '\r') {
data_scan_ctx_advance (tf, &c, 1); data_scan_ctx_advance (tf, &c, 1);
if (!data_scan_ctx_ensure_data (tf, &c, 1))
return;
} }
data_scan_ctx_advance (tf, &c, 1); data_scan_ctx_advance (tf, &c, 1);
GST_LOG ("skipped comment line in PNM header"); GST_LOG ("skipped comment line in PNM header");
if (!data_scan_ctx_ensure_data (tf, &c, 1))
return;
} }
if (!data_scan_ctx_ensure_data (tf, &c, 32) && if (!data_scan_ctx_ensure_data (tf, &c, 32) &&