aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPamplemousse <xav.maso@gmail.com>2021-07-13 14:23:24 -0700
committerPamplemousse <xav.maso@gmail.com>2021-07-14 09:09:42 -0700
commit99f8fc995b2f080cc0a6fe934c8d9c777edc3751 (patch)
tree9e5139402cee95b753a6e5936edff7db080e8178 /src
parent9cf991f421b20a2c753df1f93730ddc8ddf7af6c (diff)
libexpr: Fix read out-of-bound on the heap
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/lexer.l6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 7298419d9..27975dc9e 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -38,11 +38,13 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
loc->first_line = loc->last_line;
loc->first_column = loc->last_column;
- while (len--) {
+ for (size_t i = 0; i < len; i++) {
switch (*s++) {
case '\r':
- if (*s == '\n') /* cr/lf */
+ if (*s == '\n') { /* cr/lf */
+ i++;
s++;
+ }
/* fall through */
case '\n':
++loc->last_line;