qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 10/10] crypto: Introduce x509 utils


From: Peter Maydell
Subject: Re: [PULL 10/10] crypto: Introduce x509 utils
Date: Tue, 18 Mar 2025 16:44:41 +0000

On Mon, 9 Sept 2024 at 15:21, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> From: Dorjoy Chowdhury <dorjoychy111@gmail.com>
>
> An utility function for getting fingerprint from X.509 certificate
> has been introduced. Implementation only provided using gnutls.

Hi; recent changes in the codebase mean that one of Coverity's
"maybe this needs an error check" heuristics is now triggering
for this code (CID 1593155):

> +int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
> +                                      QCryptoHashAlgorithm alg,
> +                                      uint8_t *result,
> +                                      size_t *resultlen,
> +                                      Error **errp)
> +{
> +    int ret = -1;
> +    int hlen;
> +    gnutls_x509_crt_t crt;
> +    gnutls_datum_t datum = {.data = cert, .size = size};
> +
> +    if (alg >= G_N_ELEMENTS(qcrypto_to_gnutls_hash_alg_map)) {
> +        error_setg(errp, "Unknown hash algorithm");
> +        return -1;
> +    }
> +
> +    if (result == NULL) {
> +        error_setg(errp, "No valid buffer given");
> +        return -1;
> +    }
> +
> +    gnutls_x509_crt_init(&crt);

gnutls_x509_crt_init() can fail and return a negative value
on error -- should we be checking for and handling this
error case ?

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]