From: Barry Warsaw Date: Wed, 28 Nov 2001 21:01:56 +0000 (+0000) Subject: weakref_repr(), proxy_repr(): Conversion of sprintf() to X-Git-Tag: v2.2.1c1~669 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d586756dc5ef15688fb21edef98664509aeaae4a;p=python weakref_repr(), proxy_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer overrun avoidance. --- diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 6261a8703f..fb58ff4c7f 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -131,13 +131,15 @@ weakref_repr(PyWeakReference *self) { char buffer[256]; if (PyWeakref_GET_OBJECT(self) == Py_None) { - sprintf(buffer, "", - (long)(self)); + PyOS_snprintf(buffer, sizeof(buffer), "", + (long)(self)); } else { - sprintf(buffer, "", - (long)(self), PyWeakref_GET_OBJECT(self)->ob_type->tp_name, - (long)(PyWeakref_GET_OBJECT(self))); + PyOS_snprintf(buffer, sizeof(buffer), + "", + (long)(self), + PyWeakref_GET_OBJECT(self)->ob_type->tp_name, + (long)(PyWeakref_GET_OBJECT(self))); } return PyString_FromString(buffer); } @@ -265,9 +267,10 @@ static PyObject * proxy_repr(PyWeakReference *proxy) { char buf[160]; - sprintf(buf, "", proxy, - PyWeakref_GET_OBJECT(proxy)->ob_type->tp_name, - PyWeakref_GET_OBJECT(proxy)); + PyOS_snprintf(buf, sizeof(buf), + "", proxy, + PyWeakref_GET_OBJECT(proxy)->ob_type->tp_name, + PyWeakref_GET_OBJECT(proxy)); return PyString_FromString(buf); }