bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] grammar: fix memory access bug


From: Slava Barinov
Subject: [PATCH] grammar: fix memory access bug
Date: Tue, 25 Jul 2017 17:16:27 +0300

The alphanum is not NULL-terminated, so strspn performs access to stack out of
the array.

Signed-off-by: Slava Barinov <address@hidden>
---
 src/parse-gram.y | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/parse-gram.y b/src/parse-gram.y
index 5a0b2006..993daea6 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -780,11 +780,12 @@ translate_code_braceless (char *code, location loc)
 static void
 add_param (param_type type, char *decl, location loc)
 {
-  static char const alphanum[26 + 26 + 1 + 10] =
+  static char const alphanum[26 + 26 + 1 + 10 + 1] =
     "abcdefghijklmnopqrstuvwxyz"
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "_"
-    "0123456789";
+    "0123456789"
+    "\0";
 
   char const *name_start = NULL;
   {
-- 
2.13.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]