From ec4982761bb75e96f2d6ee37e588a52d05e228c4 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 20 Jan 1995 16:59:12 +0000 Subject: fix strncpy call (uninitialized memory read) --- Parser/parsetok.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Parser/parsetok.c b/Parser/parsetok.c index ce79ce6..5e7957e 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -168,7 +168,8 @@ parsetok(tok, g, start, err_ret) int len = tok->inp - tok->buf; err_ret->text = malloc(len + 1); if (err_ret->text != NULL) { - strncpy(err_ret->text, tok->buf, len+1); + if (len > 0) + strncpy(err_ret->text, tok->buf, len); err_ret->text[len] = '\0'; } } -- cgit v0.12