]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASN.1: Fix check for strdup() success
authorEkaterina Orlova <vorobushek.ok@gmail.com>
Fri, 21 Apr 2023 14:35:39 +0000 (15:35 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 21 Apr 2023 15:58:00 +0000 (08:58 -0700)
It seems there is a misprint in the check of strdup() return code that
can lead to NULL pointer dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 4520c6a49af8 ("X.509: Add simple ASN.1 grammar compiler")
Signed-off-by: Ekaterina Orlova <vorobushek.ok@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: keyrings@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org
Link: https://lore.kernel.org/r/20230315172130.140-1-vorobushek.ok@gmail.com/
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/asn1_compiler.c

index 7b6756a8c15d99440078dbfbb2b323abf376ed45..4c3f645065a45bf8105d31c3cc1c335fdb9defd2 100644 (file)
@@ -625,7 +625,7 @@ int main(int argc, char **argv)
        p = strrchr(argv[1], '/');
        p = p ? p + 1 : argv[1];
        grammar_name = strdup(p);
-       if (!p) {
+       if (!grammar_name) {
                perror(NULL);
                exit(1);
        }