From 8ff06515526c97628b47d8223b73d5376287a9b4 Mon Sep 17 00:00:00 2001 From: willow Date: Thu, 19 Feb 2026 19:30:07 -0500 Subject: [PATCH] parse: deny non-digit after minus in getint also: '0' <= c <= '9' -> isdigit(c) Signed-off-by: willow --- parse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parse.c b/parse.c index 7ab3ea5..a063367 100644 --- a/parse.c +++ b/parse.c @@ -215,12 +215,15 @@ getint() n = 0; c = fgetc(inf); m = (c == '-'); - if (m) + if (m) { c = fgetc(inf); + if (!isdigit(c)) + err("integer expected"); + } do { n = 10*n + (c - '0'); c = fgetc(inf); - } while ('0' <= c && c <= '9'); + } while (isdigit(c)); ungetc(c, inf); if (m) n = 1 + ~n;