PyGrammar_LabelRepr(): Conversion of sprintf() to PyOS_snprintf() for

buffer overrun avoidance.
This commit is contained in:
Barry Warsaw 2001-11-28 21:04:25 +00:00
parent 58ab084ac6
commit b97c969fee
1 changed files with 5 additions and 4 deletions

View File

@ -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;
}
}