patch to fix locale behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

It's a repost of my previous patch for GetLocaleInfoA (it has been
dropped ?) with the same fix applied to GetNumberFormatA and
GetCurrencyFormatA (as shown in my locale regression test).

Mehmet

Changelog
Fix GetLocaleInfoA /GetNumberFormatA /GetCurrencyFormatA to
work as Windows (first fill buffer then test buffer length)
since some app rely on this bug.







diff -ur /home/mehmet/CVS/wine/ole/ole2nls.c ./ole2nls.c
--- /home/mehmet/CVS/wine/ole/ole2nls.c	Sun Apr 28 15:42:21 2002
+++ ./ole2nls.c	Thu May 23 18:54:38 2002
@@ -574,8 +574,9 @@
     }
     /* if len=0 return only the length, don't touch the buffer*/
     if (len) {
-	lstrcpynA(buf,retString,len);
-	return strlen(buf) + 1;
+	/* Like Windows we copy len bytes to buffer and we check len after */
+	strncpy(buf,retString,len);
+	return (len < strlen(retString) + 1)? 0 : strlen(retString)+1 ;
     }
     return strlen(retString)+1;
 }
@@ -3275,9 +3276,8 @@
         retVal = strlen(sDestination) + 1;
     else           
     {
-        strncpy (lpNumberStr, sDestination, cchNumber-1);
-        *(lpNumberStr+cchNumber-1) = '\0';   /* ensure we got a NULL at the end */
-        retVal = strlen(lpNumberStr);
+        strncpy (lpNumberStr, sDestination, cchNumber);
+	retVal = cchNumber < (strlen(sDestination)+1) ? 0: strlen(sDestination)+1;
     }
           
     return retVal;
@@ -3531,9 +3531,8 @@
 
     else
     {
-        strncpy (lpCurrencyStr, pDestination, cchCurrency-1);
-        *(lpCurrencyStr+cchCurrency-1) = '\0';   /* ensure we got a NULL at the end */
-        return  strlen(lpCurrencyStr);
+        strncpy (lpCurrencyStr, pDestination, cchCurrency);
+	return (cchCurrency < (strlen(pDestination)+1) ? 0: strlen(pDestination)+1);
     }    
 }
 
Only in .: ole2nls.c~






[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux