Module Name: src Committed By: rillig Date: Fri Mar 14 21:48:10 UTC 2025
Modified Files: src/bin/expr: expr.y Log Message: expr: fix out-of-bounds memory read for empty command line argument To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/bin/expr/expr.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/expr/expr.y diff -u src/bin/expr/expr.y:1.46 src/bin/expr/expr.y:1.47 --- src/bin/expr/expr.y:1.46 Thu Jun 11 13:08:07 2020 +++ src/bin/expr/expr.y Fri Mar 14 21:48:10 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: expr.y,v 1.46 2020/06/11 13:08:07 kamil Exp $ */ +/* $NetBSD: expr.y,v 1.47 2025/03/14 21:48:10 rillig Exp $ */ /*_ * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ %{ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: expr.y,v 1.46 2020/06/11 13:08:07 kamil Exp $"); +__RCSID("$NetBSD: expr.y,v 1.47 2025/03/14 21:48:10 rillig Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -400,6 +400,8 @@ yylex(void) if (!p) retval = 0; + else if (p[0] == '\0') + retval = STRING; else if (p[1] == '\0') { const char *w = strchr(x, p[0]); if (w) {