profile.c

Aric Stewart aric at codeweavers.com
Tue Jun 5 10:42:59 CDT 2001


When reusing some of this code I found two potential bugs. It appears
that if not properly cast to unsigned the checksum can incorrectly
report as wrong with the structs. 

Then when i used this code under windows i found that i had to cast to
an unsigned char before shifting for the value to work correctly. This
may not be the case for linux but it does not hurt to have it in.

-aric
-------------- next part --------------
Index: files/profile.c
===================================================================
RCS file: /home/wine/wine/files/profile.c,v
retrieving revision 1.49
diff -u -u -r1.49 profile.c
--- files/profile.c	2001/05/09 17:31:34	1.49
+++ files/profile.c	2001/06/05 15:20:02
@@ -1704,7 +1704,7 @@
 		    b = ( (c > '9') ? (c - 'A' + 10) : (c - '0') ) << 4;
 		    c = toupper(*p);
 		    b +=  (c > '9') ? (c - 'A' + 10) : (c - '0');
-	            if (b == (chksum & 0xff)) /* checksums match ? */
+	            if ((unsigned char)b == (chksum & 0xff)) /* checksums match ? */
                         ret = TRUE;
                 }
             }
@@ -1767,8 +1767,8 @@
     outstring = HeapAlloc( GetProcessHeap(), 0, bufsize*2 + 2 + 1);
     p = outstring;
     for (binbuf = (LPBYTE)buf; binbuf < (LPBYTE)buf+bufsize; binbuf++) {
-      *p++ = hex[*binbuf >> 4];
-      *p++ = hex[*binbuf & 0xf];
+      *p++ = hex[(unsigned char)(*binbuf) >> 4];
+      *p++ = hex[(unsigned char)(*binbuf) & 0xf];
       sum += *binbuf;
     }
     /* checksum is sum & 0xff */


More information about the wine-patches mailing list