summaryrefslogtreecommitdiffstats
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-08-14 15:12:03 (GMT)
committerGuido van Rossum <guido@python.org>1992-08-14 15:12:03 (GMT)
commit96caaee8360762683629c4e6c440a2854f89983c (patch)
treec0a6d4428f86c8ea8353a560edf2cc86f8c31ce7 /Python/modsupport.c
parent6d946f98bd233efa676b7a05cb01cd0ca92549c0 (diff)
downloadcpython-96caaee8360762683629c4e6c440a2854f89983c.zip
cpython-96caaee8360762683629c4e6c440a2854f89983c.tar.gz
cpython-96caaee8360762683629c4e6c440a2854f89983c.tar.bz2
check for embedded \0 in strings for z and s formats
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 9f7a5b5..352a5fb 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -206,6 +206,10 @@ do_arg(arg, p_format, p_va)
*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 @@ do_arg(arg, p_format, p_va)
*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 @@ int getargs(va_alist) va_dcl
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;
}