printf-format-fix.c revision c4529ff75e8068cb63e47e455d99aea9bdf412bf
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenstatic const char *
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenfix_format_real(const char *fmt, const char *p, unsigned int *len_r)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* we'll assume that there's only one %m in the format string.
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen this simplifies the code and there's really no good reason to have
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen it multiple times. */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* @UNSAFE */
a12399903f415a7e14c2816cffa2f7a09dcbb097Timo Sirainenstatic const char *
a12399903f415a7e14c2816cffa2f7a09dcbb097Timo Sirainenprintf_format_fix_noalloc(const char *format, unsigned int *len_r)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen const char *p;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen if (*p++ == '%') {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen switch (*p) {
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenconst char *printf_format_fix_get_len(const char *format, unsigned int *len_r)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen const char *ret;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen ret = printf_format_fix_noalloc(format, len_r);
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainenconst char *printf_format_fix(const char *format)
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen const char *ret;
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen unsigned int len;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen ret = printf_format_fix_noalloc(format, &len);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenconst char *printf_format_fix_unsafe(const char *format)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen unsigned int len;