[Python-checkins] CVS: python/dist/src/Modules _testcapimodule.c,1.12,1.13 posixmodule.c,2.208,2.209 readline.c,2.39,2.40

M.-A. Lemburg lemburg@users.sourceforge.net
Wed, 28 Nov 2001 03:47:02 -0800


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

Modified Files:
	_testcapimodule.c posixmodule.c readline.c 
Log Message:
Fixes for possible buffer overflows in sprintf() usages.



Index: _testcapimodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_testcapimodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** _testcapimodule.c	2001/09/30 05:09:37	1.12
--- _testcapimodule.c	2001/11/28 11:46:59	1.13
***************
*** 37,41 ****
  {
  	char buf[1024];
! 	sprintf(buf, "%s #define == %d but sizeof(%s) == %d",
  		fatname, expected, typename, got);
  	PyErr_SetString(TestError, buf);
--- 37,41 ----
  {
  	char buf[1024];
! 	sprintf(buf, "%.200s #define == %d but sizeof(%.200s) == %d",
  		fatname, expected, typename, got);
  	PyErr_SetString(TestError, buf);

Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.208
retrieving revision 2.209
diff -C2 -d -r2.208 -r2.209
*** posixmodule.c	2001/11/24 09:31:44	2.208
--- posixmodule.c	2001/11/28 11:46:59	2.209
***************
*** 5788,5792 ****
      ULONG     values[QSV_MAX+1];
      PyObject *v;
!     char     *ver, tmp[10];
  
      Py_BEGIN_ALLOW_THREADS
--- 5788,5792 ----
      ULONG     values[QSV_MAX+1];
      PyObject *v;
!     char     *ver, tmp[50];
  
      Py_BEGIN_ALLOW_THREADS

Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.39
retrieving revision 2.40
diff -C2 -d -r2.39 -r2.40
*** readline.c	2001/10/19 01:18:43	2.39
--- readline.c	2001/11/28 11:46:59	2.40
***************
*** 166,170 ****
  	PyObject *function = Py_None;
  	char buf[80];
! 	sprintf(buf, "|O:set_%s", funcname);
  	if (!PyArg_ParseTuple(args, buf, &function))
  		return NULL;
--- 166,170 ----
  	PyObject *function = Py_None;
  	char buf[80];
! 	sprintf(buf, "|O:set_%.50s", funcname);
  	if (!PyArg_ParseTuple(args, buf, &function))
  		return NULL;
***************
*** 182,186 ****
  	}
  	else {
! 		sprintf(buf, "set_%s(func): argument not callable", funcname);
  		PyErr_SetString(PyExc_TypeError, buf);
  		return NULL;
--- 182,186 ----
  	}
  	else {
! 		sprintf(buf, "set_%.50s(func): argument not callable", funcname);
  		PyErr_SetString(PyExc_TypeError, buf);
  		return NULL;