Mercurial > cpython-lru_cache-weakref
diff Python/importdl.c @ 5389:5a9706965a4e legacy-trunk
Avoid some potential (though unlikely) sprintf buffer overflows.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 30 Apr 1997 19:07:54 +0000 |
| parents | 5880384d7c71 |
| children | 487ad0327ae1 |
line wrap: on
line diff
--- a/Python/importdl.c Wed Apr 30 19:00:27 1997 +0000 +++ b/Python/importdl.c Wed Apr 30 19:07:54 1997 +0000 @@ -298,7 +298,8 @@ (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec); err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); if ( err ) { - sprintf(buf, "%s: %s", pathname, PyMac_StrError(err)); + sprintf(buf, "%.255s: %.200s", + pathname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; } @@ -318,7 +319,8 @@ kLoadCFrag, &connID, &mainAddr, errMessage); if ( err ) { - sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, + sprintf(buf, "%.*s: %.200s", + errMessage[0], errMessage+1, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; @@ -326,7 +328,8 @@ /* Locate the address of the correct init function */ err = FindSymbol(connID, Pstring(funcname), &symAddr, &class); if ( err ) { - sprintf(buf, "%s: %s", funcname, PyMac_StrError(err)); + sprintf(buf, "%s: %.200s", + funcname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; }
