[Python-checkins] CVS: python/dist/src/Parser grammar1.c,2.12,2.13

Barry Warsaw bwarsaw@users.sourceforge.net
Wed, 28 Nov 2001 13:04:27 -0800


Update of /cvsroot/python/python/dist/src/Parser
In directory usw-pr-cvs1:/tmp/cvs-serv16791

Modified Files:
	grammar1.c 
Log Message:
PyGrammar_LabelRepr(): Conversion of sprintf() to PyOS_snprintf() for
buffer overrun avoidance.


Index: grammar1.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/grammar1.c,v
retrieving revision 2.12
retrieving revision 2.13
diff -C2 -d -r2.12 -r2.13
*** grammar1.c	2000/09/01 23:29:28	2.12
--- grammar1.c	2001/11/28 21:04:25	2.13
***************
*** 1,3 ****
! 
  /* Grammar subroutines needed by parser */
  
--- 1,3 ----
! #include "Python.h"
  /* Grammar subroutines needed by parser */
  
***************
*** 40,44 ****
  	else if (ISNONTERMINAL(lb->lb_type)) {
  		if (lb->lb_str == NULL) {
! 			sprintf(buf, "NT%d", lb->lb_type);
  			return buf;
  		}
--- 40,44 ----
  	else if (ISNONTERMINAL(lb->lb_type)) {
  		if (lb->lb_str == NULL) {
! 			PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type);
  			return buf;
  		}
***************
*** 50,55 ****
  			return _PyParser_TokenNames[lb->lb_type];
  		else {
! 			sprintf(buf, "%.32s(%.32s)",
! 				_PyParser_TokenNames[lb->lb_type], lb->lb_str);
  			return buf;
  		}
--- 50,56 ----
  			return _PyParser_TokenNames[lb->lb_type];
  		else {
! 			PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)",
! 				      _PyParser_TokenNames[lb->lb_type],
! 				      lb->lb_str);
  			return buf;
  		}