Don't use apachetop, so just build tested. Looks like someone was
overzealous with their NULL usage. Also fix what looks like a write past
the end of the array.

- Matthew Martin



diff --git patches/patch-src_apachetop_cc patches/patch-src_apachetop_cc
new file mode 100644
index 00000000000..0132e95966f
--- /dev/null
+++ patches/patch-src_apachetop_cc
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+Index: src/apachetop.cc
+--- src/apachetop.cc.orig
++++ src/apachetop.cc
+@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
+       hm->create(cf.circle_size);
+       /* }}} */
+ 
+-      memset(&gstats, (char) NULL, sizeof(gstats));
++      memset(&gstats, 0, sizeof(gstats));
+       gstats.start = time(NULL);
+ 
+       signal(SIGINT, &catchsig);
+@@ -465,7 +465,7 @@ int main(int argc, char *argv[])
+                                       continue;
+                               }
+ 
+-                              *nextline = (char) NULL;
++                              *nextline = '\0';
+                               ++nextline;
+ 
+                               /* which parser? */
diff --git patches/patch-src_apachetop_cc.orig 
patches/patch-src_apachetop_cc.orig
new file mode 100644
index 00000000000..ca729eb2dd2
--- /dev/null
+++ patches/patch-src_apachetop_cc.orig
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: src/apachetop.cc
+--- src/apachetop.cc.orig
++++ src/apachetop.cc
+@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
+       hm->create(cf.circle_size);
+       /* }}} */
+ 
+-      memset(&gstats, (char) NULL, sizeof(gstats));
++      memset(&gstats, 0, sizeof(gstats));
+       gstats.start = time(NULL);
+ 
+       signal(SIGINT, &catchsig);
diff --git patches/patch-src_display_cc patches/patch-src_display_cc
new file mode 100644
index 00000000000..7b45ed8d454
--- /dev/null
+++ patches/patch-src_display_cc
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Index: src/display.cc
+--- src/display.cc.orig
++++ src/display.cc
+@@ -1145,7 +1145,7 @@ void display_histogram()
+        * characters high to draw the barchart
+       */
+       float bar_height[hist_width];
+-      char line[hist_width];
++      char line[hist_width + 1];
+       for(i = 0 ; i < hist_width ; i++)
+               bar_height[i] = 0;
+ 
+@@ -1191,7 +1191,7 @@ void display_histogram()
+ 
+               /* compose a row of hashes */
+               memset(line, ' ', hist_width);
+-              line[hist_width] = (char)NULL;
++              line[hist_width] = '\0';
+               for(j = 0 ; j < hist_width ; ++j)
+               {
+                       if (bar_height[j] > y_scale)
+@@ -1203,7 +1203,7 @@ void display_histogram()
+       }
+ 
+       memset(horiz_line, '-', hist_width);
+-      horiz_line[hist_width] = (char)NULL;
++      horiz_line[hist_width] = '\0';
+       mvprintw(HISTOGRAM_START + hist_height, 2, "0+%*s",
+           hist_width, horiz_line);
+       
diff --git patches/patch-src_display_cc.orig patches/patch-src_display_cc.orig
new file mode 100644
index 00000000000..ddc053387dc
--- /dev/null
+++ patches/patch-src_display_cc.orig
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+Index: src/display.cc
+--- src/display.cc.orig
++++ src/display.cc
+@@ -1145,7 +1145,7 @@ void display_histogram()
+        * characters high to draw the barchart
+       */
+       float bar_height[hist_width];
+-      char line[hist_width];
++      char line[hist_width + 1];
+       for(i = 0 ; i < hist_width ; i++)
+               bar_height[i] = 0;
+ 
+@@ -1191,7 +1191,7 @@ void display_histogram()
+ 
+               /* compose a row of hashes */
+               memset(line, ' ', hist_width);
+-              line[hist_width] = (char)NULL;
++              line[hist_width] = '\0';
+               for(j = 0 ; j < hist_width ; ++j)
+               {
+                       if (bar_height[j] > y_scale)
diff --git patches/patch-src_hits_circle_cc patches/patch-src_hits_circle_cc
new file mode 100644
index 00000000000..55678bed305
--- /dev/null
+++ patches/patch-src_hits_circle_cc
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: src/hits_circle.cc
+--- src/hits_circle.cc.orig
++++ src/hits_circle.cc
+@@ -24,7 +24,7 @@ int Hits_Circle::create(unsigned int passed_size)
+       }
+ 
+       reqcount = bytecount = 0;
+-      memset(rc_summary, (char) NULL, sizeof(rc_summary));
++      memset(rc_summary, 0, sizeof(rc_summary));
+ 
+       return 0;
+ }
diff --git patches/patch-src_log_cc patches/patch-src_log_cc
new file mode 100644
index 00000000000..e6cf4f15af1
--- /dev/null
+++ patches/patch-src_log_cc
@@ -0,0 +1,59 @@
+$OpenBSD$
+
+Index: src/log.cc
+--- src/log.cc.orig
++++ src/log.cc
+@@ -37,7 +37,7 @@ int CommonLogParser::parse(char *logline, struct logbi
+       if (!bufcp)
+               return -1;
+       
+-      *bufcp = (char) NULL;
++      *bufcp = '\0';
+       ++bufcp;
+ 
+       /* quickly figure out if this is an IP or a host. We do this by
+@@ -172,7 +172,7 @@ int CommonLogParser::parse(char *logline, struct logbi
+       /* find the end of referrer and null it */
+       if (!(bufcp = strchr(bufsp, '"')))
+               return -1;
+-      *bufcp = (char) NULL;
++      *bufcp = '\0';
+ 
+       /* unless they want to keep it, skip over the protocol, ie http:// */
+       if ((cf.preserve_ref_protocol == 0) && (bufcp = strstr(bufsp, "://")))
+@@ -230,7 +230,7 @@ char *LogParser::processURL(char **buf) /* {{{ */
+               return NULL;
+ 
+       /* null the space in front of it */
+-      *endptr = (char) NULL;
++      *endptr = '\0';
+ 
+       /* TODO maybe we can use the protocol someday.. */
+ 
+@@ -258,7 +258,7 @@ int LogParser::mungeURL(char **url, int *length) /* {{
+       char *bufcp, *endptr, *workptr;
+ 
+       endptr = *url + *length;
+-      *endptr = (char) NULL;
++      *endptr = '\0';
+ 
+       /* do we want to keep the query string? */
+       if (!cf.keep_querystring)
+@@ -273,7 +273,7 @@ int LogParser::mungeURL(char **url, int *length) /* {{
+                       if (workptr < endptr)
+                       {
+                               /* we're ok */
+-                              *workptr = (char) NULL;
++                              *workptr = '\0';
+                               bufcp = workptr+1;
+                       }
+               }
+@@ -308,7 +308,7 @@ int LogParser::mungeURL(char **url, int *length) /* {{
+                       if (workptr == endptr)
+                               bufcp = workptr;
+               }
+-              *bufcp = (char) NULL;
++              *bufcp = '\0';
+       }
+ 
+ 

Reply via email to