]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix strncpy call (uninitialized memory read)
authorGuido van Rossum <guido@python.org>
Fri, 20 Jan 1995 16:59:12 +0000 (16:59 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 20 Jan 1995 16:59:12 +0000 (16:59 +0000)
Parser/parsetok.c

index ce79ce64a5206ac92d897b4c7587c248a4faa8e7..5e7957e29953f8c604913961140f11bf9a148a6e 100644 (file)
@@ -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';
                        }
                }