From 8d532683386121e70810b0d7c6642cc2c2b89cb0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 25 Nov 2016 20:16:06 +0000 Subject: Fix build bugs. It builds! Two things remain to do: - how to pass SNI information to libtls - how to detect cert issuer key type for ECC in bearssl --- src/sbearssl/sbearssl_cert_readfile.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/sbearssl/sbearssl_cert_readfile.c') diff --git a/src/sbearssl/sbearssl_cert_readfile.c b/src/sbearssl/sbearssl_cert_readfile.c index 6090624..6cc78c1 100644 --- a/src/sbearssl/sbearssl_cert_readfile.c +++ b/src/sbearssl/sbearssl_cert_readfile.c @@ -10,7 +10,7 @@ #include #include -int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa) ; +int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa) { char buf[BUFFER_INSIZE] ; int fd = open_readb(fn) ; @@ -18,12 +18,14 @@ int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa) ; genalloc pems = GENALLOC_ZERO ; sbearssl_pemobject *p ; size_t certsbase = genalloc_len(sbearssl_cert, certs) ; + size_t sabase = sa->len ; size_t n ; 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(buf, n, &pems, sa) ; + r = sbearssl_pem_decode_from_buffer(&b, &pems, sa) ; if (r) { fd_close(fd) ; return r ; } fd_close(fd) ; p = genalloc_s(sbearssl_pemobject, &pems) ; @@ -46,7 +48,8 @@ int sbearssl_cert_readfile (char const *fn, genalloc *certs, stralloc *sa) ; fail: if (certswasnull) genalloc_free(sbearssl_cert, certs) ; else genalloc_setlen(sbearssl_cert, certs, certsbase) ; - stralloc_free(&sa) ; - genalloc_free(sbearssl_pemobject, pems) ; + if (sawasnull) stralloc_free(sa) ; + else sa->len = sabase ; + genalloc_free(sbearssl_pemobject, &pems) ; return r ; } -- cgit v1.3.1