svn commit: samba r16859 - in trunk/source/lib: .

jpeach at samba.org jpeach at samba.org
Fri Jul 7 06:30:00 GMT 2006


Author: jpeach
Date: 2006-07-07 06:30:00 +0000 (Fri, 07 Jul 2006)
New Revision: 16859

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16859

Log:
Don't use LL for long long literals in str_conv_size().

Modified:
   trunk/source/lib/util_str.c


Changeset:
Modified: trunk/source/lib/util_str.c
===================================================================
--- trunk/source/lib/util_str.c	2006-07-07 06:05:26 UTC (rev 16858)
+++ trunk/source/lib/util_str.c	2006-07-07 06:30:00 UTC (rev 16859)
@@ -2339,19 +2339,33 @@
         }
 
         if (*end) {
+		SMB_OFF_T lval_orig = lval;
+
                 if (strwicmp(end, "K") == 0) {
-                        lval *= 1024ULL;
+                        lval *= (SMB_OFF_T)1024;
                 } else if (strwicmp(end, "M") == 0) {
-                        lval *= (1024ULL * 1024ULL);
+                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024);
                 } else if (strwicmp(end, "G") == 0) {
-                        lval *= (1024ULL * 1024ULL * 1024ULL);
+                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+				(SMB_OFF_T)1024);
                 } else if (strwicmp(end, "T") == 0) {
-                        lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
+                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+				(SMB_OFF_T)1024 * (SMB_OFF_T)1024);
                 } else if (strwicmp(end, "P") == 0) {
-                        lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
+                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+				(SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+				(SMB_OFF_T)1024);
                 } else {
                         return 0;
                 }
+
+		/* Primitive attempt to detect wrapping on platforms with
+		 * 4-byte SMB_OFF_T. It's better to let the caller handle
+		 * a failure than some random number.
+		 */
+		if (lval_orig <= lval) {
+			return 0;
+		}
         }
 
 	return lval;



More information about the samba-cvs mailing list