Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec49827

Browse files
committed
fix strncpy call (uninitialized memory read)
1 parent badadd2 commit ec49827

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Parser/parsetok.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ parsetok(tok, g, start, err_ret)
168168
int len = tok->inp - tok->buf;
169169
err_ret->text = malloc(len + 1);
170170
if (err_ret->text != NULL) {
171-
strncpy(err_ret->text, tok->buf, len+1);
171+
if (len > 0)
172+
strncpy(err_ret->text, tok->buf, len);
172173
err_ret->text[len] = '\0';
173174
}
174175
}

0 commit comments

Comments
 (0)