From 6115ab76d2c877a33ed84fdbd7e65e1b922a49aa Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sat, 29 Jun 2013 13:52:46 -0700 Subject: [PATCH] Diagnose calling compile_et -v without another argument Output an error message instead of crashing with a segmentation fault due to a NULL pointer dereference. Bug found by Mayhem and reported by Alexandre Rebert. Change-Id: I484f76411ed6899ea9af81256c1d392a84830d16 Reviewed-on: http://gerrit.openafs.org/10024 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/comerr/compile_et.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/comerr/compile_et.c b/src/comerr/compile_et.c index 560cc1b08..c73433fce 100644 --- a/src/comerr/compile_et.c +++ b/src/comerr/compile_et.c @@ -212,6 +212,12 @@ main(int argc, char **argv) got_prefix = arg; } else if (strcmp(arg, "v") == 0) { arg = *++argv, argc--; + if (arg == NULL) { + fprintf(stderr, "%s: -v option requires an argument\n", + whoami); + usage(); + exit(1); + } version = atoi(arg); if (version != 1 && version != 2) { fprintf(stderr, "%s: unknown control argument -`%s'\n", -- 2.39.5