From: Fredrik Tolf Date: Wed, 10 Nov 2021 18:34:13 +0000 (+0100) Subject: htparser: Fixed readcrtchain bug. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=2e90aa50d776226ee9d7499e2e97fd22a1d6d3fe;p=ashd.git htparser: Fixed readcrtchain bug. --- diff --git a/src/ssl-gnutls.c b/src/ssl-gnutls.c index 5a44214..8e3a825 100644 --- a/src/ssl-gnutls.c +++ b/src/ssl-gnutls.c @@ -438,7 +438,7 @@ static int readcrtchain(struct certbuffer *ret, struct charbuf *pem) for(i = 0, p = NULL; i < sizeof(headers) / sizeof(*headers); i++) { f = memmem(pem->b, pem->d, headers[i], strlen(headers[i])); - if((p == NULL) || (f < p)) + if((f != NULL) && ((p == NULL) || (f < p))) p = f; } if(p == NULL) @@ -453,7 +453,7 @@ static int readcrtchain(struct certbuffer *ret, struct charbuf *pem) bufadd(*ret, crt); for(i = 0, p2 = NULL; i < sizeof(headers) / sizeof(*headers); i++) { f = memmem(p + 1, pem->d - (p + 1 - pem->b), headers[i], strlen(headers[i])); - if((p2 == NULL) || (f < p2)) + if((f != NULL) && ((p2 == NULL) || (f < p2))) p2 = f; } } while((p = p2) != NULL);