Skip to contentSkip to conversation

ASN.1: Fix check for strdup() success

PATCH New Ekaterina Orlova 1 participant 1 message Mar 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 scripts/asn1_compiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/asn1_compiler.c +1 -1
index 7b6756a8c15d..4c3f645065a4 100644
@@ -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);
 	}
Signature · 1 line
2.34.1