x509asn1: fix operator order in do_pubkey

Check the range before reading data, as it would otherwise read one byte
too many.

Reported-by: Andrew Nesbit
Closes #21533
This commit is contained in:
Daniel Stenberg 2026-05-07 23:35:40 +02:00
parent 3ce10063f1
commit cda0268593
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -1013,7 +1013,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum, const char *algo,
return 1;
/* Compute key length. */
for(q = elem.beg; !*q && q < elem.end; q++)
for(q = elem.beg; q < elem.end && !*q; q++)
;
len = ((elem.end - q) * 8);
if(len) {