summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-10-18 10:15:16 +0000
committerLaurent Bercot <ska@appnovation.com>2021-10-18 10:15:16 +0000
commit2732e2cfdbe1015bba929fdf4bc80521f3e32b16 (patch)
treed1c6c9830622e20c4d27bba6791d11c7ddb58b48
parent30892adec131029fb7f1d80e01ea50a084e75dab (diff)
downloads6-networking-2732e2cfdbe1015bba929fdf4bc80521f3e32b16.tar.xz
Fix error case in readbigpem
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/sbearssl/sbearssl_cert_readbigpem.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sbearssl/sbearssl_cert_readbigpem.c b/src/sbearssl/sbearssl_cert_readbigpem.c
index 9e6339a..7c6fc5b 100644
--- a/src/sbearssl/sbearssl_cert_readbigpem.c
+++ b/src/sbearssl/sbearssl_cert_readbigpem.c
@@ -24,11 +24,12 @@ int sbearssl_cert_readbigpem (char const *fn, genalloc *certs, stralloc *sa)
size_t i = 0 ;
int certswasnull = !genalloc_s(sbearssl_cert, certs) ;
int sawasnull = !sa->s ;
- int r ;
if (fd < 0) return -1 ;
- r = sbearssl_pem_decode_from_buffer(&b, &pems, sa) ;
- fd_close(fd) ;
- if (r) return r ;
+ {
+ int r = sbearssl_pem_decode_from_buffer(&b, &pems, sa) ;
+ fd_close(fd) ;
+ if (r) return r ;
+ }
p = genalloc_s(sbearssl_pemobject, &pems) ;
n = genalloc_len(sbearssl_pemobject, &pems) ;
for (; i < n ; i++)
@@ -51,5 +52,5 @@ int sbearssl_cert_readbigpem (char const *fn, genalloc *certs, stralloc *sa)
if (sawasnull) stralloc_free(sa) ;
else sa->len = sabase ;
genalloc_free(sbearssl_pemobject, &pems) ;
- return r ;
+ return -1 ;
}