Mercurial > cpython-lru_cache-weakref
diff Python/modsupport.c @ 957:5c6cdb58a801 legacy-trunk
check for embedded \0 in strings for z and s formats
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 14 Aug 1992 15:12:03 +0000 |
| parents | 39134c99c923 |
| children | 09b48604855f |
line wrap: on
line diff
--- a/Python/modsupport.c Fri Aug 14 13:49:30 1992 +0000 +++ b/Python/modsupport.c Fri Aug 14 15:12:03 1992 +0000 @@ -206,6 +206,10 @@ *q = getstringsize(arg); format++; } + else if (strlen(*p) != getstringsize(arg)) { + err_setstr(ValueError, "embedded '\\0' in string arg"); + return 0; + } break; } @@ -225,6 +229,10 @@ *q = getstringsize(arg); format++; } + else if (*p != NULL && strlen(*p) != getstringsize(arg)) { + err_setstr(ValueError, "embedded '\\0' in string arg"); + return 0; + } break; } @@ -292,8 +300,11 @@ va_end(va); if (!ok) { char buf[256]; - sprintf(buf, "bad argument list (format '%s')", format); - err_setstr(TypeError, buf); + if (!err_occurred()) { + sprintf(buf, "bad argument list (format '%s')", + format); + err_setstr(TypeError, buf); + } } return ok; }
