Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASN.1: Fix check for strdup() success

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>

authored by

Ekaterina Orlova and committed by
Linus Torvalds
5a43001c 2af3e53a

+1 -1
+1 -1
scripts/asn1_compiler.c
··· 625 625 p = strrchr(argv[1], '/'); 626 626 p = p ? p + 1 : argv[1]; 627 627 grammar_name = strdup(p); 628 - if (!p) { 628 + if (!grammar_name) { 629 629 perror(NULL); 630 630 exit(1); 631 631 }