From: Thomas Pornin Date: Sat, 12 Nov 2016 14:58:57 +0000 (+0100) Subject: Fixed error reporting in case of PEM encoding error when decoding certificates. X-Git-Tag: v0.4~58 X-Git-Url: https://bearssl.org/gitweb//home/git/?p=BearSSL;a=commitdiff_plain;h=133705ee65f12c50698a6d8ae734681f4f48019f;hp=16d0864818cdf24e4fb1d722fe71456c03e3fc17 Fixed error reporting in case of PEM encoding error when decoding certificates. --- diff --git a/tools/files.c b/tools/files.c index 07af6c4..21c8166 100644 --- a/tools/files.c +++ b/tools/files.c @@ -172,6 +172,7 @@ decode_pem(const void *src, size_t len, size_t *num) bvector bv = VEC_INIT; int inobj; + *num = 0; br_pem_decoder_init(&pc); buf = src; inobj = 0; @@ -267,6 +268,9 @@ read_certificates(const char *fname, size_t *num) pos = decode_pem(buf, len, &num_pos); xfree(buf); + if (pos == NULL) { + return NULL; + } for (u = 0; u < num_pos; u ++) { if (eqstr(pos[u].name, "CERTIFICATE") || eqstr(pos[u].name, "X509 CERTIFICATE"))