diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2004-02-08 13:31:32 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2004-02-08 13:31:32 +0000 |
commit | 649ce0516a36b7e87600ecbae62cda37b14c22f8 (patch) | |
tree | 57dc9201483779740a24c048eb97b3631f40d2e1 | |
parent | 2f1d799c7fdb37463bdfea3b87bc6cda42518b1f (diff) |
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.
-rw-r--r-- | apps/asn1pars.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 8cc13ee2d1..4ec6ec2741 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -301,7 +301,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"); |