It's undefined how flags, precision or length modifiers are handled with %n,
so make sure we catch all of them to detect an unwanted %n.
static const char *
printf_format_fix_noalloc(const char *format, size_t *len_r)
{
+ static const char *printf_skip_chars = "# -+'I.*0123456789hlLjzt";
const char *ret, *p, *p2;
p = ret = format;
while ((p2 = strchr(p, '%')) != NULL) {
p = p2+1;
+ while (*p != '\0' && strchr(printf_skip_chars, *p) != NULL)
+ p++;
switch (*p) {
case 'n':
i_panic("%%n modifier used");
{
static const char *fatals[] = {
"no no no %n's",
+ "no no no %-1234567890123n's with extra stuff",
"%m allowed once, but not twice: %m",
"%m must not obscure a later %n",
"definitely can't have a tailing %",