[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8310: Fix bug 327 (part 2): Cast char to unsigned char before pass (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2006-08-31 13:39:51 -0400 (Thu, 31 Aug 2006)
New Revision: 8310

Modified:
   tor/trunk/
   tor/trunk/src/common/compat.h
   tor/trunk/src/common/container.c
   tor/trunk/src/common/util.c
   tor/trunk/src/or/config.c
   tor/trunk/src/or/routerparse.c
Log:
 r8692@Kushana:  nickm | 2006-08-31 13:38:07 -0400
 Fix bug 327 (part 2): Cast char to unsigned char before passing to toupper/tolower.  (Follow the same idiom as with isupper and friends, in case we run into the same problem on SGI or whereever it was.)



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r8692] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2006-08-31 17:39:47 UTC (rev 8309)
+++ tor/trunk/src/common/compat.h	2006-08-31 17:39:51 UTC (rev 8310)
@@ -155,6 +155,9 @@
 #define TOR_ISLOWER(c)   islower((int)(unsigned char)(c))
 #define TOR_ISUPPER(c)   isupper((int)(unsigned char)(c))
 
+#define TOR_TOLOWER(c)   ((char)tolower((int)(unsigned char)(c)))
+#define TOR_TOUPPER(c)   ((char)toupper((int)(unsigned char)(c)))
+
 #ifdef MS_WINDOWS
 #define _SHORT_FILE_ (tor_fix_source_file(__FILE__))
 const char *tor_fix_source_file(const char *fname);

Modified: tor/trunk/src/common/container.c
===================================================================
--- tor/trunk/src/common/container.c	2006-08-31 17:39:47 UTC (rev 8309)
+++ tor/trunk/src/common/container.c	2006-08-31 17:39:51 UTC (rev 8310)
@@ -824,7 +824,7 @@
  *       iter = strmap_iter_next_rmv(iter);
  *       free(val);
  *    } else {
- *       for (;*cp;cp++) *cp = toupper(*cp);
+ *       for (;*cp;cp++) *cp = TOR_TOUPPER(*cp);
  *       iter = strmap_iter_next(iter);
  *    }
  * }

Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2006-08-31 17:39:47 UTC (rev 8309)
+++ tor/trunk/src/common/util.c	2006-08-31 17:39:51 UTC (rev 8310)
@@ -308,7 +308,7 @@
 tor_strlower(char *s)
 {
   while (*s) {
-    *s = tolower(*s);
+    *s = TOR_TOLOWER(*s);
     ++s;
   }
 }
@@ -319,7 +319,7 @@
 tor_strupper(char *s)
 {
   while (*s) {
-    *s = toupper(*s);
+    *s = TOR_TOUPPER(*s);
     ++s;
   }
 }

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-08-31 17:39:47 UTC (rev 8309)
+++ tor/trunk/src/or/config.c	2006-08-31 17:39:51 UTC (rev 8310)
@@ -1737,7 +1737,7 @@
       *cp = '\0';
       break;
     }
-    *cp = tolower(*cp);
+    *cp = TOR_TOLOWER(*cp);
   }
 
   /* Strip invalid characters. */

Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c	2006-08-31 17:39:47 UTC (rev 8309)
+++ tor/trunk/src/or/routerparse.c	2006-08-31 17:39:51 UTC (rev 8310)
@@ -1279,7 +1279,7 @@
   len = strlen(s);
   cp = tmp = tor_malloc(len+2);
   for (idx = 0; idx < len; ++idx) {
-    tmp[idx] = tolower(s[idx]);
+    tmp[idx] = TOR_TOLOWER(s[idx]);
   }
   tmp[len]='\n';
   tmp[len+1]='\0';