[Rpm-maint] [rpm-software-management/rpm] verifySignature(): package signatures must be PGPSIGTYPE_BINARY (PR #1801)

Panu Matilainen notifications at github.com
Thu Oct 21 07:55:52 UTC 2021


@pmatilai commented on this pull request.



> @@ -426,6 +426,11 @@ static int pgpVersion(const uint8_t *h, size_t hlen, uint8_t *version)
     return 0;
 }
 
+int pgpSignatureType(pgpDigParams _digp) {
+    assert(_digp->tag == PGPTAG_SIGNATURE);

Imagine for a moment what life would be like if the kernel and libc did this: blew up your program each time they get input that isn't just so.

Never, ever assert when you can just handle the error. 

If you want to keep contributing to rpm, please take some time to digest the overall style of how we do things. If you look around the codebase, you'll find that assert() is not used like this here. There are reasons for that. Instead you'll find that for public APIs we also generally check for NULL pointers as a type of EINVAL rather than blow up - in fact this would blow up on NULL pointer dereference *in* the assert. That's not a way to do an interface where you can just trivially handle the error instead, and return `-1` for it.

-- 
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/1801#pullrequestreview-785333297
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211021/65e7e3d7/attachment.html>


More information about the Rpm-maint mailing list