mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
Fix handling of -offset and -length in asn1parse tool.
If -offset exceeds -length of data available exit with an error. Don't read past end of total data available when -offset supplied. If -length exceeds total available truncate it.
This commit is contained in:
parent
1751034669
commit
37ead9be0b
@ -333,7 +333,15 @@ bad:
|
||||
num=tmplen;
|
||||
}
|
||||
|
||||
if (length == 0) length=(unsigned int)num;
|
||||
if (offset >= num)
|
||||
{
|
||||
BIO_printf(bio_err, "Error: offset too large\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
num -= offset;
|
||||
|
||||
if ((length == 0) || (length > num)) length=(unsigned int)num;
|
||||
if(derout) {
|
||||
if(BIO_write(derout, str + offset, length) != (int)length) {
|
||||
BIO_printf(bio_err, "Error writing output\n");
|
||||
|
Loading…
Reference in New Issue
Block a user