avcodec/pnm: skip reading trailing bytes in get_pnm()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 1 Aug 2019 19:12:07 +0000 (21:12 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 23 Aug 2019 20:26:50 +0000 (22:26 +0200)
None of the keys we support is that long and other keys
lead to decoder failure. None of the values is expected
to be longer, they are all numbers or short keywords.

This simplifies the code

Fixes: Timeout (9sec->43ms)
Fixes: 15177/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAM_fuzzer-5080556716425216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/pnm.c

index cadfa7569ec90cedcfda862387a56f3a1ad09d6a..b4e5d3076baa95000873e6a58ffe0138db348397 100644 (file)
@@ -58,8 +58,6 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
         c = *bs++;
     }
     *s = '\0';
-    while (bs < end && !pnm_space(c))
-        c = *bs++;
     sc->bytestream = bs;
 }