]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2007-07-12 Havoc Pennington <hp@redhat.com>
authorHavoc Pennington <hp@redhat.com>
Thu, 12 Jul 2007 22:18:05 +0000 (22:18 +0000)
committerHavoc Pennington <hp@redhat.com>
Thu, 12 Jul 2007 22:18:05 +0000 (22:18 +0000)
* dbus/dbus-sysdeps-util.c (_dbus_sysdeps_test): invert the test
for parsing hex as double to be sure it fails to work

* dbus/dbus-sysdeps.c (_dbus_string_parse_double): don't allow hex numbers.

ChangeLog
dbus/dbus-sysdeps-util.c
dbus/dbus-sysdeps.c

index ce6ac551d21a0c8feb064d84ecadb9ac3ba21305..eb8b2876c0b09fe215763f9f68c99d5e34efea51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-12  Havoc Pennington  <hp@redhat.com>
+
+       * dbus/dbus-sysdeps-util.c (_dbus_sysdeps_test): invert the test
+       for parsing hex as double to be sure it fails to work
+
+       * dbus/dbus-sysdeps.c (_dbus_string_parse_double): don't allow hex numbers.
+
 2007-07-10  Havoc Pennington  <hp@redhat.com>
 
        * dbus/dbus-connection.c (struct DBusConnection): Fix from Olivier
index 1f6ceb9b670004af131e6db0140e5ed44000ac91..4d1d0daa7e7995bf3ff10adcf91e95810aae58ea 100644 (file)
@@ -142,20 +142,10 @@ _dbus_sysdeps_test (void)
     }
 
   _dbus_string_init_const (&str, "0xff");
-  if (!_dbus_string_parse_double (&str,
-                                 0, &val, &pos))
-    {
-      _dbus_warn ("Failed to parse double");
-      exit (1);
-    }
-  if (ABS (0xff - val) > 1e-6)
-    {
-      _dbus_warn ("Failed to parse 0xff correctly, got: %f\n", val);
-      exit (1);
-    }
-  if (pos != 4)
+  if (_dbus_string_parse_double (&str,
+                                 0, &val, &pos))
     {
-      _dbus_warn ("_dbus_string_parse_double of \"0xff\" returned wrong position %d", pos);
+      _dbus_warn ("Should not have parsed hex as double\n");
       exit (1);
     }
 
index c310b281f1dc4c2991757da631079ca081931cf2..cd3e20e75eaf1ad97c914866567ea6713860a990 100644 (file)
@@ -750,6 +750,12 @@ _dbus_string_parse_double (const DBusString *str,
   p = _dbus_string_get_const_data_len (str, start,
                                        _dbus_string_get_length (str) - start);
 
+  /* parsing hex works on linux but isn't portable, so intercept it
+   * here to get uniform behavior.
+   */
+  if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X'))
+    return FALSE;
+  
   end = NULL;
   errno = 0;
   v = ascii_strtod (p, &end);