summaryrefslogtreecommitdiffstats
path: root/Parser/parsetok.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-20 16:59:12 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-20 16:59:12 (GMT)
commitec4982761bb75e96f2d6ee37e588a52d05e228c4 (patch)
treefd51013420a5de32dbf907bb54c1de3caa682592 /Parser/parsetok.c
parentbadadd216579e625f6bd94363414ed872aa62cfc (diff)
downloadcpython-ec4982761bb75e96f2d6ee37e588a52d05e228c4.zip
cpython-ec4982761bb75e96f2d6ee37e588a52d05e228c4.tar.gz
cpython-ec4982761bb75e96f2d6ee37e588a52d05e228c4.tar.bz2
fix strncpy call (uninitialized memory read)
Diffstat (limited to 'Parser/parsetok.c')
-rw-r--r--Parser/parsetok.c3
1 files changed, 2 insertions, 1 deletions
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';
}
}