diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2004-02-08 13:30:04 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2004-02-08 13:30:04 +0000 |
commit | 37ead9be0b990b94ec6dbf466cdc05f53c18d442 (patch) | |
tree | 5b66fb4f854d3b0f482f328b8588a89713d2d293 /apps/asn1pars.c | |
parent | 1751034669af1e687f4fefeff0bbbf98b4adb05a (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.
Diffstat (limited to 'apps/asn1pars.c')
-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 5f8ba5e730..88db0d1978 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -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"); |