check for embedded \0 in strings for z and s formats

This commit is contained in:
Guido van Rossum 1992-08-14 15:12:03 +00:00
parent 6d946f98bd
commit 96caaee836
1 changed files with 13 additions and 2 deletions

View File

@ -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,9 +300,12 @@ int getargs(va_alist) va_dcl
va_end(va);
if (!ok) {
char buf[256];
sprintf(buf, "bad argument list (format '%s')", format);
if (!err_occurred()) {
sprintf(buf, "bad argument list (format '%s')",
format);
err_setstr(TypeError, buf);
}
}
return ok;
}