diff Python/exceptions.c @ 25093:ae1469e468a0 legacy-trunk

Limit the length of attribute names in exception messages to prevent buffer overflows (spotted by Neal Norwitz).
author Walter Dörwald <walter@livinglogic.de>
date Mon, 02 Sep 2002 16:10:06 +0000
parents 0337dad8403e
children 6a85a1c9d33d
line wrap: on
line diff
--- a/Python/exceptions.c	Mon Sep 02 15:54:06 2002 +0000
+++ b/Python/exceptions.c	Mon Sep 02 16:10:06 2002 +0000
@@ -852,7 +852,7 @@
     if (!attr)
 	return -1;
     if (!PyInt_Check(attr)) {
-	PyErr_Format(PyExc_TypeError, "%s attribute must be int", name);
+	PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name);
 	Py_DECREF(attr);
 	return -1;
     }
@@ -884,7 +884,7 @@
     if (!attr)
 	return NULL;
     if (!PyString_Check(attr)) {
-	PyErr_Format(PyExc_TypeError, "%s attribute must be str", name);
+	PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name);
 	Py_DECREF(attr);
 	return NULL;
     }
@@ -914,7 +914,7 @@
     if (!attr)
 	return NULL;
     if (!PyUnicode_Check(attr)) {
-	PyErr_Format(PyExc_TypeError, "%s attribute must be unicode", name);
+	PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name);
 	Py_DECREF(attr);
 	return NULL;
     }