diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-11-23 11:10:52 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-11-23 11:10:52 +0000 |
commit | 88a8138266b5d8d1a60c1e43b92b431c048ef92d (patch) | |
tree | 8de86796eb1d9ed401d664daf04cff5539380bb1 | |
parent | b76e1bc6d4b7ccf02ab85281118d5346a696ad7e (diff) |
re-align these copies of the a2i_*(3) code with f_string.c rev. 1.19
to fix the same double-counting of the backslash
and to make the parsing stricter in the same way;
OK tb@
-rw-r--r-- | lib/libcrypto/asn1/f_enum.c | 20 | ||||
-rw-r--r-- | lib/libcrypto/asn1/f_int.c | 20 |
2 files changed, 12 insertions, 28 deletions
diff --git a/lib/libcrypto/asn1/f_enum.c b/lib/libcrypto/asn1/f_enum.c index cc4b7dfc916..e5256705728 100644 --- a/lib/libcrypto/asn1/f_enum.c +++ b/lib/libcrypto/asn1/f_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_enum.c,v 1.16 2018/04/25 11:48:21 tb Exp $ */ +/* $OpenBSD: f_enum.c,v 1.17 2021/11/23 11:10:51 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -123,19 +123,12 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) buf[--i] = '\0'; if (i == 0) goto err_sl; - again = (buf[i - 1] == '\\'); - - for (j = 0; j < i; j++) { - if (!(((buf[j] >= '0') && (buf[j] <= '9')) || - ((buf[j] >= 'a') && (buf[j] <= 'f')) || - ((buf[j] >= 'A') && (buf[j] <= 'F')))) { - i = j; - break; - } - } + if (buf[i - 1] == '\\') { + i--; + again = 1; + } else + again = 0; buf[i] = '\0'; - /* We have now cleared all the crap off the end of the - * line */ if (i < 2) goto err_sl; @@ -148,7 +141,6 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) } } k = 0; - i -= again; if (i % 2 != 0) { ASN1error(ASN1_R_ODD_NUMBER_OF_CHARS); goto err; diff --git a/lib/libcrypto/asn1/f_int.c b/lib/libcrypto/asn1/f_int.c index d03fafe87d3..8ce9d20d5f4 100644 --- a/lib/libcrypto/asn1/f_int.c +++ b/lib/libcrypto/asn1/f_int.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_int.c,v 1.20 2018/05/13 13:48:08 jsing Exp $ */ +/* $OpenBSD: f_int.c,v 1.21 2021/11/23 11:10:51 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -126,19 +126,12 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) buf[--i] = '\0'; if (i == 0) goto err_sl; - again = (buf[i - 1] == '\\'); - - for (j = 0; j < i; j++) { - if (!(((buf[j] >= '0') && (buf[j] <= '9')) || - ((buf[j] >= 'a') && (buf[j] <= 'f')) || - ((buf[j] >= 'A') && (buf[j] <= 'F')))) { - i = j; - break; - } - } + if (buf[i - 1] == '\\') { + i--; + again = 1; + } else + again = 0; buf[i] = '\0'; - /* We have now cleared all the crap off the end of the - * line */ if (i < 2) goto err_sl; @@ -151,7 +144,6 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) } } k = 0; - i -= again; if (i % 2 != 0) { ASN1error(ASN1_R_ODD_NUMBER_OF_CHARS); goto err; |