From: Fabian Keil <fk@fabiankeil.de>
Date: Mon, 26 Jul 2010 11:21:47 +0000 (+0000)
Subject: In log_error(), assert that ival and sval have reasonable values. There's no reason... 
X-Git-Tag: v_3_0_17~112
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/@default-cgi@/static/faq/@default-cgi@show-url-info?a=commitdiff_plain;h=791cc31cc94b00d0720ebba201c43102d132e2b3;p=privoxy.git

In log_error(), assert that ival and sval have reasonable values. There's no reason not to abort() if they don't.
---

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 != '\\'))