Mercurial > cpython-lru_cache-weakref
diff Python/dynload_win.c @ 21077:379fc66f4c96 legacy-trunk
Use PyOS_snprintf instead of sprintf.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Wed, 28 Nov 2001 20:42:20 +0000 |
| parents | 225c7dd17e37 |
| children | 8142f8d668a0 |
line wrap: on
line diff
--- a/Python/dynload_win.c Wed Nov 28 20:37:25 2001 +0000 +++ b/Python/dynload_win.c Wed Nov 28 20:42:20 2001 +0000 @@ -159,7 +159,7 @@ dl_funcptr p; char funcname[258], *import_python; - sprintf(funcname, "init%.200s", shortname); + PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); #ifdef MS_WIN32 { @@ -201,9 +201,9 @@ /* Problem: could not get the error message. This should not happen if called correctly. */ if (theLength == 0) { - sprintf(errBuf, - "DLL load failed with error code %d", - errorCode); + PyOS_snprintf(errBuf, sizeof(errBuf), + "DLL load failed with error code %d", + errorCode); } else { size_t len; /* For some reason a \r\n @@ -225,16 +225,16 @@ } else { char buffer[256]; - sprintf(buffer,"python%d%d.dll", + PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); if (import_python && strcasecmp(buffer,import_python)) { - sprintf(buffer, - "Module use of %.150s conflicts " - "with this version of Python.", - import_python); + PyOS_snprintf(buffer, sizeof(buffer), + "Module use of %.150s conflicts " + "with this version of Python.", + import_python); PyErr_SetString(PyExc_ImportError,buffer); FreeLibrary(hDLL); return NULL; @@ -251,14 +251,16 @@ strchr(pathname, '/') == NULL) { /* Prefix bare filename with ".\" */ - sprintf(pathbuf, ".\\%-.13s", pathname); + PyOS_snprintf(pathbuf, sizeof(pathbuf), + ".\\%-.13s", pathname); pathname = pathbuf; } hDLL = LoadLibrary(pathname); if (hDLL < HINSTANCE_ERROR){ char errBuf[256]; - sprintf(errBuf, - "DLL load failed with error code %d", hDLL); + PyOS_snprintf(errBuf, sizeof(errBuf), + "DLL load failed with error code %d", + hDLL); PyErr_SetString(PyExc_ImportError, errBuf); return NULL; }
