Module Name: src Committed By: christos Date: Sat Feb 20 01:18:03 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: ckgetopt.c Log Message: Prevent crashing when options are NULL in libc while linting src/lib/libc/posix1e/acl_from_text.c To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/xlint/lint1/ckgetopt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/ckgetopt.c diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.2 src/usr.bin/xlint/lint1/ckgetopt.c:1.3 --- src/usr.bin/xlint/lint1/ckgetopt.c:1.2 Fri Feb 19 09:44:29 2021 +++ src/usr.bin/xlint/lint1/ckgetopt.c Fri Feb 19 20:18:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ckgetopt.c,v 1.2 2021/02/19 14:44:29 rillig Exp $ */ +/* $NetBSD: ckgetopt.c,v 1.3 2021/02/20 01:18:02 christos Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: ckgetopt.c,v 1.2 2021/02/19 14:44:29 rillig Exp $"); +__RCSID("$NetBSD: ckgetopt.c,v 1.3 2021/02/20 01:18:02 christos Exp $"); #endif #include <stdbool.h> @@ -100,7 +100,7 @@ is_getopt_call(const tnode_t *tn, char * static void check_unlisted_option(char opt) { - if (opt == '?') + if (opt == '?' || ck.options == NULL) return; const char *optptr = strchr(ck.options, opt); @@ -116,6 +116,9 @@ check_unlisted_option(char opt) static void check_unhandled_option(void) { + if (ck.unhandled_options == NULL) + return; + for (const char *opt = ck.unhandled_options; *opt != '\0'; opt++) { if (*opt == ' ' || *opt == ':') continue;