[or-cvs] r13639: Fix a spelling error and clean up a recent veracode-induced (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Thu Feb 21 03:42:56 UTC 2008


Author: nickm
Date: 2008-02-20 22:42:56 -0500 (Wed, 20 Feb 2008)
New Revision: 13639

Modified:
   tor/trunk/
   tor/trunk/src/common/container.c
   tor/trunk/src/or/config.c
Log:
 r18294 at catbus:  nickm | 2008-02-20 22:42:44 -0500
 Fix a spelling error and clean up a recent veracode-induced integer overflow check.  Both spotted by Chris Palmer.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r18294] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/container.c
===================================================================
--- tor/trunk/src/common/container.c	2008-02-21 03:38:46 UTC (rev 13638)
+++ tor/trunk/src/common/container.c	2008-02-21 03:42:56 UTC (rev 13639)
@@ -89,10 +89,12 @@
 void
 smartlist_add_all(smartlist_t *s1, const smartlist_t *s2)
 {
-  smartlist_ensure_capacity(s1, s1->num_used + s2->num_used);
-  tor_assert(s1->capacity >= s1->num_used+s2->num_used);
+  int new_size = s1->num_used + s2->num_used;
+  tor_assert(new_size >= s1->num_used); /* check for overflow. */
+  smartlist_ensure_capacity(s1, new_size);
+  tor_assert(s1->capacity >= new_size);
   memcpy(s1->list + s1->num_used, s2->list, s2->num_used*sizeof(void*));
-  s1->num_used += s2->num_used;
+  s1->num_used = new_size;
 }
 
 /** Remove all elements E from sl such that E==element.  Preserve

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-02-21 03:38:46 UTC (rev 13638)
+++ tor/trunk/src/or/config.c	2008-02-21 03:42:56 UTC (rev 13639)
@@ -4754,7 +4754,7 @@
                "to \"%s\".  This could be a bug in Tor; please tell "
                "the developers.", fname, fname2);
       if (rename(fname, fname2) < 0) {
-        log_warn(LD_BUG, "Weirdly, I couldn't even mode the state aside. The "
+        log_warn(LD_BUG, "Weirdly, I couldn't even move the state aside. The "
                  "OS gave an error of %s", strerror(errno));
       }
     }



More information about the tor-commits mailing list