Commit f223e8fd authored by Ana María Martínez Gómez's avatar Ana María Martínez Gómez Committed by Dr. Matthias St. Pierre
Browse files

Support directories with "." in x509_load_serial()

Use `strrchr` to get a pointer to the last occurrence of `.` in the
path string, instead of the first one with `strchr`.  This prevent the
path to be wrongly split if it contains several `.`, and not only the
one for the extension.

Fixes https://github.com/openssl/openssl/issues/6489

.

CLA: trivial

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
Reviewed-by: default avatarMatthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6566)
parent eaf39a9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -916,7 +916,7 @@ static ASN1_INTEGER *x509_load_serial(const char *CAfile,
    BIGNUM *serial = NULL;
    BIGNUM *serial = NULL;


    if (serialfile == NULL) {
    if (serialfile == NULL) {
        const char *p = strchr(CAfile, '.');
        const char *p = strrchr(CAfile, '.');
        size_t len = p != NULL ? (size_t)(p - CAfile) : strlen(CAfile);
        size_t len = p != NULL ? (size_t)(p - CAfile) : strlen(CAfile);


        buf = app_malloc(len + sizeof(POSTFIX), "serial# buffer");
        buf = app_malloc(len + sizeof(POSTFIX), "serial# buffer");