diff options
author | Barry Warsaw <barry@python.org> | 2001-11-28 21:04:25 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-11-28 21:04:25 (GMT) |
commit | b97c969fee0f3c4d67cac738703fd98ff95bd3f3 (patch) | |
tree | 07c6d263eb830d53fa9731b72d578bd66791bdcb | |
parent | 58ab084ac6094f3201169dd6c5259b6bd99e4926 (diff) | |
download | cpython-b97c969fee0f3c4d67cac738703fd98ff95bd3f3.zip cpython-b97c969fee0f3c4d67cac738703fd98ff95bd3f3.tar.gz cpython-b97c969fee0f3c4d67cac738703fd98ff95bd3f3.tar.bz2 |
PyGrammar_LabelRepr(): Conversion of sprintf() to PyOS_snprintf() for
buffer overrun avoidance.
-rw-r--r-- | Parser/grammar1.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Parser/grammar1.c b/Parser/grammar1.c index b2631b7..45af139 100644 --- a/Parser/grammar1.c +++ b/Parser/grammar1.c @@ -1,4 +1,4 @@ - +#include "Python.h" /* Grammar subroutines needed by parser */ #include "pgenheaders.h" @@ -39,7 +39,7 @@ PyGrammar_LabelRepr(label *lb) return "EMPTY"; else if (ISNONTERMINAL(lb->lb_type)) { if (lb->lb_str == NULL) { - sprintf(buf, "NT%d", lb->lb_type); + PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type); return buf; } else @@ -49,8 +49,9 @@ PyGrammar_LabelRepr(label *lb) if (lb->lb_str == NULL) return _PyParser_TokenNames[lb->lb_type]; else { - sprintf(buf, "%.32s(%.32s)", - _PyParser_TokenNames[lb->lb_type], lb->lb_str); + PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)", + _PyParser_TokenNames[lb->lb_type], + lb->lb_str); return buf; } } |