diff options
author | David Benjamin <davidben@chromium.org> | 2015-01-26 03:04:47 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-01-26 21:37:47 +0300 |
commit | 2a0e72f08a1990a41a279af8e885b345ae67d075 (patch) | |
tree | fbf30db8659c4a54e5142f62d604e6d7918befb6 /crypto | |
parent | df1cda345f1cd60a13f4497e34a468b62f128a6f (diff) |
Fix segfault with empty fields as last in the config.
(Imported from upstream's 2747d73c1466c487daf64a1234b6fe2e8a62ac75.)
Also fix up some stylistic issues in conf.c and clarify empty case in
documentation.
Change-Id: Ibacabfab2339d7566d51db4b3ac4579aec0d1fbf
Reviewed-on: https://boringssl-review.googlesource.com/3023
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/conf/conf.c | 21 | ||||
-rw-r--r-- | crypto/x509/asn1_gen.c | 3 |
2 files changed, 16 insertions, 8 deletions
diff --git a/crypto/conf/conf.c b/crypto/conf/conf.c index 520416ae..b8dab95a 100644 --- a/crypto/conf/conf.c +++ b/crypto/conf/conf.c @@ -715,27 +715,32 @@ int CONF_parse_list(const char *list, char sep, int remove_whitespace, lstart = list; for (;;) { if (remove_whitespace) { - while (*lstart && isspace((unsigned char)*lstart)) + while (*lstart && isspace((unsigned char)*lstart)) { lstart++; + } } p = strchr(lstart, sep); - if (p == lstart || !*lstart) + if (p == lstart || !*lstart) { ret = list_cb(NULL, 0, arg); - else { - if (p) + } else { + if (p) { tmpend = p - 1; - else + } else { tmpend = lstart + strlen(lstart) - 1; + } if (remove_whitespace) { - while (isspace((unsigned char)*tmpend)) + while (isspace((unsigned char)*tmpend)) { tmpend--; + } } ret = list_cb(lstart, tmpend - lstart + 1, arg); } - if (ret <= 0) + if (ret <= 0) { return ret; - if (p == NULL) + } + if (p == NULL) { return 1; + } lstart = p + 1; } } diff --git a/crypto/x509/asn1_gen.c b/crypto/x509/asn1_gen.c index 6fcae7bf..9246b93a 100644 --- a/crypto/x509/asn1_gen.c +++ b/crypto/x509/asn1_gen.c @@ -287,6 +287,9 @@ static int asn1_cb(const char *elem, int len, void *bitstr) int tmp_tag, tmp_class; + if (elem == NULL) + return 0; + for(i = 0, p = elem; i < len; p++, i++) { /* Look for the ':' in name value pairs */ |