X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=wgtpkg-certs.c;h=1d8b97638472afff56e829913b3897f9b8d53b6c;hb=82a1641c0570e6548649dac932853959854cd706;hp=c103c5134fe2f9a9c968a7466b67b87ffbd2e4b9;hpb=ad9428741b9a8f91e68829433bd643eee101a665;p=src%2Fapp-framework-main.git diff --git a/wgtpkg-certs.c b/wgtpkg-certs.c index c103c51..1d8b976 100644 --- a/wgtpkg-certs.c +++ b/wgtpkg-certs.c @@ -42,16 +42,22 @@ static int add_certificate_x509(X509 *x) static int add_certificate_bin(const char *bin, int len) { int rc; - const unsigned char *b = (const unsigned char *)bin; - X509 *x = d2i_X509(NULL, &b, len); - if (x == NULL) { - syslog(LOG_ERR, "d2i_X509 failed"); - return -1; + const char *b, *e; + b = bin; + e = bin + len; + while (len) { + X509 *x = d2i_X509(NULL, (const unsigned char **)&b, e-b); + if (x == NULL) { + syslog(LOG_ERR, "d2i_X509 failed"); + return -1; + } + rc = add_certificate_x509(x); + if (rc) { + X509_free(x); + return rc; + } } - rc = add_certificate_x509(x); - if (rc) - X509_free(x); - return rc; + return 0; } int add_certificate_b64(const char *b64)