diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-06-25 17:40:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 17:40:05 (GMT) |
commit | 571cefd8c7933f4917739dde43171558f109d63c (patch) | |
tree | a3208bf782aceca98c8b60198cf781a0481f4729 /Parser | |
parent | f4f8a714b5fe0e83d63c54cdf39e8d8920047e6c (diff) | |
download | cpython-571cefd8c7933f4917739dde43171558f109d63c.zip cpython-571cefd8c7933f4917739dde43171558f109d63c.tar.gz cpython-571cefd8c7933f4917739dde43171558f109d63c.tar.bz2 |
[3.13] gh-120155: Fix Coverity issue in parse_string() (GH-120997) (#121005)
gh-120155: Fix Coverity issue in parse_string() (GH-120997)
(cherry picked from commit 769aea332940f03c3e5b1ad9badd6635c1ac992a)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/string_parser.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c index bacfd81..93ad92b 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -229,9 +229,14 @@ _PyPegen_parse_string(Parser *p, Token *t) PyErr_BadInternalCall(); return NULL; } + /* Skip the leading quote char. */ s++; len = strlen(s); + // gh-120155: 's' contains at least the trailing quote, + // so the code '--len' below is safe. + assert(len >= 1); + if (len > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "string to parse is too long"); return NULL; |