sprintf -> PyOS_snprintf in some "obviously safe" cases.

Also changed <>-style #includes to ""-style in some places where the
former didn't make sense.
This commit is contained in:
Tim Peters 2001-11-28 20:27:42 +00:00
parent 05bd787c6c
commit 885d457709
15 changed files with 61 additions and 42 deletions

View file

@ -19,7 +19,7 @@ raiseTestError(const char* test_name, const char* msg)
if (strlen(test_name) + strlen(msg) > sizeof(buf) - 50)
PyErr_SetString(TestError, "internal error msg too large");
else {
sprintf(buf, "%s: %s", test_name, msg);
PyOS_snprintf(buf, sizeof(buf), "%s: %s", test_name, msg);
PyErr_SetString(TestError, buf);
}
return NULL;
@ -36,7 +36,8 @@ sizeof_error(const char* fatname, const char* typename,
int expected, int got)
{
char buf[1024];
sprintf(buf, "%.200s #define == %d but sizeof(%.200s) == %d",
PyOS_snprintf(buf, sizeof(buf),
"%.200s #define == %d but sizeof(%.200s) == %d",
fatname, expected, typename, got);
PyErr_SetString(TestError, buf);
return (PyObject*)NULL;