William Orr <mailto:w...@worrbase.com>
August 17, 2013 3:51 PM
Loop variables are declared as ints when they're compared to size_ts. This only becomes an issue when the config file or the output buffer becomes unreasonably large.

Index: libexec/spamd/grey.c
===================================================================
RCS file: /cvs/src/libexec/spamd/grey.c,v
retrieving revision 1.52
diff -u -b -w -p -r1.52 grey.c
--- libexec/spamd/grey.c    2 Oct 2012 15:26:17 -0000    1.52
+++ libexec/spamd/grey.c    17 Aug 2013 22:36:43 -0000
@@ -362,7 +362,7 @@ bad:
 void
 freeaddrlists(void)
 {
-    int i;
+    size_t i;

     if (whitelist != NULL)
         for (i = 0; i < whitecount; i++) {
Index: libexec/spamd/spamd.c
===================================================================
RCS file: /cvs/src/libexec/spamd/spamd.c,v
retrieving revision 1.112
diff -u -b -w -p -r1.112 spamd.c
--- libexec/spamd/spamd.c    19 Jun 2012 17:43:40 -0000    1.112
+++ libexec/spamd/spamd.c    17 Aug 2013 22:36:43 -0000
@@ -265,7 +265,7 @@ void
 parse_configs(void)
 {
     char *start, *end;
-    int i;
+    size_t i;

     if (cbu == cbs) {
         char *tmp;
@@ -371,7 +371,7 @@ append_error_string(struct con *cp, size
     char *c = cp->obuf + off;
     char *s = fmt;
     size_t len = cp->osize - off;
-    int i = 0;
+    size_t i = 0;

     if (off == 0)
         lastcont = 0;

Whoops, missed the downcast of time_t to int in the sscanfs. Here's a revised patch.

Index: src/libexec/spamd/grey.c
===================================================================
RCS file: /cvs/src/libexec/spamd/grey.c,v
retrieving revision 1.52
diff -u -b -w -p -r1.52 grey.c
--- src/libexec/spamd/grey.c    2 Oct 2012 15:26:17 -0000    1.52
+++ src/libexec/spamd/grey.c    18 Aug 2013 02:02:00 -0000
@@ -362,7 +362,7 @@ bad:
 void
 freeaddrlists(void)
 {
-    int i;
+    size_t i;

     if (whitelist != NULL)
         for (i = 0; i < whitecount; i++) {
Index: src/libexec/spamd/spamd.c
===================================================================
RCS file: /cvs/src/libexec/spamd/spamd.c,v
retrieving revision 1.112
diff -u -b -w -p -r1.112 spamd.c
--- src/libexec/spamd/spamd.c    19 Jun 2012 17:43:40 -0000    1.112
+++ src/libexec/spamd/spamd.c    18 Aug 2013 02:02:00 -0000
@@ -265,7 +265,7 @@ void
 parse_configs(void)
 {
     char *start, *end;
-    int i;
+    size_t i;

     if (cbu == cbs) {
         char *tmp;
@@ -371,7 +371,7 @@ append_error_string(struct con *cp, size
     char *c = cp->obuf + off;
     char *s = fmt;
     size_t len = cp->osize - off;
-    int i = 0;
+    size_t i = 0;

     if (off == 0)
         lastcont = 0;
@@ -1114,7 +1114,7 @@ main(int argc, char *argv[])
             greylist = 0;
             break;
         case 'G':
-            if (sscanf(optarg, "%d:%d:%d", &passtime, &greyexp,
+            if (sscanf(optarg, "%lld:%lld:%lld", &passtime, &greyexp,
&whiteexp) != 3)
                 usage();
             /* convert to seconds from minutes */

Reply via email to