diff --git a/apps/asn1parse.c b/apps/asn1parse.c index bf62f85947907..26b7cf2173a59 100644 --- a/apps/asn1parse.c +++ b/apps/asn1parse.c @@ -216,6 +216,9 @@ int asn1parse_main(int argc, char **argv) i = BIO_read(in, &(buf->data[num]), BUFSIZ); if (i <= 0) break; + /* make sure num doesn't overflow */ + if (i > LONG_MAX - num) + goto end; num += i; } }