X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/3634fc257bd0667daef14d72005cd87c735bbb24..17ba0f52b8df4e6ece849deac1b9d6b88bdc26c6:/src/src/dummies.c diff --git a/src/src/dummies.c b/src/src/dummies.c index d176befe8..197415f0c 100644 --- a/src/src/dummies.c +++ b/src/src/dummies.c @@ -20,7 +20,7 @@ alternates. */ /* We don't have the full Exim headers dragged in, but this function is used for debugging output. */ -extern int string_vformat(char *, int, char *, va_list); +extern gstring * string_vformat(gstring *, unsigned, const char *, va_list); /************************************************* @@ -56,7 +56,9 @@ flags = flags; * Handle calls to print debug output * *************************************************/ -/* The message just gets written to stderr +/* The message just gets written to stderr. +We use tainted memory to format into just so that we can handle +tainted arguments. Arguments: format a printf() format @@ -69,22 +71,24 @@ void debug_printf(char *format, ...) { va_list ap; -char buffer[1024]; +rmark reset_point = store_mark(); +gstring * g = string_get_tainted(1024, TRUE); va_start(ap, format); -if (!string_vformat(buffer, sizeof(buffer), format, ap)) +if (!string_vformat(g, 0, format, ap)) { - char *s = "**** debug string overflowed buffer ****\n"; - char *p = buffer + (int)strlen(buffer); - int maxlen = sizeof(buffer) - (int)strlen(s) - 3; - if (p > buffer + maxlen) p = buffer + maxlen; - if (p > buffer && p[-1] != '\n') *p++ = '\n'; + char * s = "**** debug string overflowed buffer ****\n"; + char * p = CS g->s + g->ptr; + int maxlen = g->size - (int)strlen(s) - 3; + if (p > g->s + maxlen) p = g->s + maxlen; + if (p > g->s && p[-1] != '\n') *p++ = '\n'; strcpy(p, s); } -fprintf(stderr, "%s", buffer); +fprintf(stderr, "%s", string_from_gstring(g)); fflush(stderr); +store_reset(reset_point); va_end(ap); } @@ -100,7 +104,7 @@ void sigalrm_handler(int sig) { sig = sig; /* Keep picky compilers happy */ -sigalrm_seen = 1; +sigalrm_seen = TRUE; }