From 791cc31cc94b00d0720ebba201c43102d132e2b3 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 26 Jul 2010 11:21:47 +0000 Subject: [PATCH] In log_error(), assert that ival and sval have reasonable values. There's no reason not to abort() if they don't. --- errlog.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/errlog.c b/errlog.c index 1579e74e..41cc453d 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.104 2010/07/26 11:20:17 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.105 2010/07/26 11:20:53 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -794,27 +794,10 @@ void log_error(int loglevel, const char *fmt, ...) * Takes 2 parameters: int length, const char * string. */ ival = va_arg(ap, int); + assert(ival >= 0); sval = va_arg(ap, char *); - if (sval == NULL) - { - format_string = "[null]"; - } - else if (ival <= 0) - { - if (0 == ival) - { - /* That's ok (but stupid) */ - tempbuf[0] = '\0'; - } - else - { - /* - * That's not ok (and even more stupid) - */ - assert(ival >= 0); - format_string = "[counted string lenght < 0]"; - } - } + assert(sval != NULL); + while ((ival-- > 0) && (length < log_buffer_size - 6)) { if (isprint((int)*sval) && (*sval != '\\')) -- 2.39.2