[Rpm-maint] [rpm-software-management/rpm] Add OpenSSL crypto backend (#129)

Tomáš Mráz notifications at github.com
Wed Jan 18 17:03:56 UTC 2017


t8m commented on this pull request.



> +}
+
+int rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
+{
+    int ret;
+    unsigned char *digest = NULL;
+    unsigned int digestlen;
+
+    if (ctx == NULL) return -1;
+
+    digestlen = EVP_MD_CTX_size(ctx->md_ctx);
+    digest = xcalloc(digestlen, sizeof(*digest));
+    if (digest == NULL) return -1;
+
+    ret = EVP_DigestFinal_ex(ctx->md_ctx, digest, &digestlen);
+    if (ret != 1) goto done;

Yes, in most places there might be both 0 and -1 returns where 0 usually indicates "regular" failures such as hash or signature verification failure and -1 some kind of "fatal" error - such as unknown hash algorithm or memory allocation error. So the safest thing for functions returning 1 as success is to use `ret != 1` or even `ret <= 0` as test for failure.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/129
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170118/13acd4e3/attachment.html>


More information about the Rpm-maint mailing list