commit 2cb0b6bd5d9c3b87a829b3f7a4c53650a548d639
parent ec23ce13015b77577740ce925fb2c9d24cd785d2
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Fri, 1 Oct 2021 01:16:42 +0200
Check if strchr returns NULL
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/parser.c b/parser.c
@@ -202,8 +202,13 @@ procid()
if (!word())
return 0;
- k = strchr(token, '[');
+ if (!(k = strchr(token, '[')))
+ return 0;
+
n = strspn(k+1, "0123456789");
+ if (n > 32)
+ return 0;
+
memcpy(str, k+1, n);
str[n] = '\0';