Commit 90584f2
committed
src/x509.c: refactor wolfSSL_PEM_read_bio_X509_CRL onto the per-block reader
ReadPemFromBioToBuffer slurps the entire BIO in one shot, so iterative
callers like wolfSSL_PEM_read_bio_X509_CRL (and by extension
wolfSSL_X509_load_crl_file's BIO branch) saw EOF after the first block
and silently dropped every CRL after the first in a multi-CRL bundle.
Refactor wolfSSL_PEM_read_bio_X509_CRL to delegate to
wolfSSL_PEM_X509_X509_CRL_X509_PKEY_read_bio, which already reads one
PEM BEGIN/END pair per call and leaves the BIO positioned just past the
END line. Loop over it so we skip past intervening cert/key blocks and
return the next CRL in the stream — matching OpenSSL's
PEM_read_bio_X509_CRL, verified against OpenSSL 3.0.13 with cases
{cert,CRL}, {CRL,cert}, {CRL,cert,CRL}, {key,CRL}, {CRL,key,CRL}: in
each case OpenSSL skips non-CRL blocks until EOF.
When the caller passes a non-NULL `x` whose `*x` is already populated,
free the previous CRL before overwriting the slot — matching the
d2i_X509_CRL reuse contract the old body relied on.
To keep both helpers visible at the new call site, drop their `static`
qualifier (wolfSSL_PEM_X509_X509_CRL_X509_PKEY_read_bio for the per-block
read, wolfSSL_X509_PKEY_free to free defensively-allocated keys parsed
from intervening non-CRL blocks). Their definitions in src/x509.c and
declarations in wolfssl/internal.h are widened from OPENSSL_ALL to
OPENSSL_EXTRA || OPENSSL_ALL so the OPENSSL_EXTRA-only build (which
compiles wolfSSL_PEM_read_bio_X509_CRL) links cleanly. The unrelated
INFO_read_bio / INFO_read_bio_X509_INFO group below them keeps its
OPENSSL_ALL gate because it depends on wolfSSL_X509_INFO_new/free that
are still OPENSSL_ALL-only.
Also register the previously-orphaned test_wolfSSL_X509_load_crl_file
(its slot in TEST_OSSL_X509_LOOKUP_DECLS was a duplicated
test_wolfSSL_X509_LOOKUP_ctrl_hash_dir entry), update its assertion for
crl2.pem (which already contains two CRLs) to expect 2 instead of 1, and
add a multi-CRL bundle case that builds a memory BIO from
crl.pem + server-cert.pem + crl2.pem and asserts that the reader walks
past the cert and returns all 3 CRLs before NULL.1 parent 1c9555c commit 90584f2
4 files changed
Lines changed: 89 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13499 | 13499 | | |
13500 | 13500 | | |
13501 | 13501 | | |
13502 | | - | |
13503 | | - | |
13504 | | - | |
13505 | | - | |
13506 | 13502 | | |
13507 | 13503 | | |
13508 | 13504 | | |
13509 | 13505 | | |
13510 | | - | |
13511 | | - | |
13512 | | - | |
13513 | | - | |
13514 | | - | |
13515 | | - | |
13516 | | - | |
13517 | | - | |
13518 | | - | |
13519 | | - | |
| 13506 | + | |
| 13507 | + | |
| 13508 | + | |
| 13509 | + | |
| 13510 | + | |
| 13511 | + | |
| 13512 | + | |
| 13513 | + | |
| 13514 | + | |
| 13515 | + | |
| 13516 | + | |
| 13517 | + | |
| 13518 | + | |
| 13519 | + | |
| 13520 | + | |
| 13521 | + | |
13520 | 13522 | | |
13521 | 13523 | | |
13522 | | - | |
13523 | | - | |
13524 | | - | |
13525 | | - | |
13526 | | - | |
13527 | | - | |
13528 | | - | |
| 13524 | + | |
| 13525 | + | |
| 13526 | + | |
| 13527 | + | |
| 13528 | + | |
13529 | 13529 | | |
13530 | 13530 | | |
13531 | | - | |
13532 | 13531 | | |
13533 | 13532 | | |
13534 | 13533 | | |
| |||
13691 | 13690 | | |
13692 | 13691 | | |
13693 | 13692 | | |
13694 | | - | |
| 13693 | + | |
13695 | 13694 | | |
13696 | 13695 | | |
13697 | 13696 | | |
| |||
13711 | 13710 | | |
13712 | 13711 | | |
13713 | 13712 | | |
13714 | | - | |
| 13713 | + | |
13715 | 13714 | | |
13716 | 13715 | | |
13717 | 13716 | | |
| |||
13737 | 13736 | | |
13738 | 13737 | | |
13739 | 13738 | | |
13740 | | - | |
| 13739 | + | |
13741 | 13740 | | |
13742 | 13741 | | |
13743 | 13742 | | |
| |||
13921 | 13920 | | |
13922 | 13921 | | |
13923 | 13922 | | |
| 13923 | + | |
| 13924 | + | |
| 13925 | + | |
13924 | 13926 | | |
13925 | 13927 | | |
13926 | 13928 | | |
| |||
14058 | 14060 | | |
14059 | 14061 | | |
14060 | 14062 | | |
14061 | | - | |
| 14063 | + | |
14062 | 14064 | | |
14063 | 14065 | | |
14064 | 14066 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
315 | 326 | | |
316 | 327 | | |
317 | 328 | | |
| |||
342 | 353 | | |
343 | 354 | | |
344 | 355 | | |
345 | | - | |
| 356 | + | |
346 | 357 | | |
347 | 358 | | |
348 | 359 | | |
| |||
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
397 | 447 | | |
398 | 448 | | |
399 | 449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7469 | 7469 | | |
7470 | 7470 | | |
7471 | 7471 | | |
| 7472 | + | |
| 7473 | + | |
| 7474 | + | |
| 7475 | + | |
| 7476 | + | |
| 7477 | + | |
| 7478 | + | |
| 7479 | + | |
| 7480 | + | |
7472 | 7481 | | |
7473 | 7482 | | |
7474 | 7483 | | |
| |||
0 commit comments