Fix range checks with -offset and -length in asn1parse
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5826)
Bernd Edlinger
6 years ago
257 | 257 | num = tmplen; |
258 | 258 | } |
259 | 259 | |
260 | if (offset >= num) { | |
260 | if (offset < 0 || offset >= num) { | |
261 | 261 | BIO_printf(bio_err, "Error: offset too large\n"); |
262 | 262 | goto end; |
263 | 263 | } |
264 | 264 | |
265 | 265 | num -= offset; |
266 | 266 | |
267 | if ((length == 0) || ((long)length > num)) | |
267 | if (length == 0 || length > (unsigned int)num) | |
268 | 268 | length = (unsigned int)num; |
269 | 269 | if (derout != NULL) { |
270 | 270 | if (BIO_write(derout, str + offset, length) != (int)length) { |