{
_dbus_string_init_const (&str, valid_signatures[i]);
- if (!_dbus_validate_signature (&str, 0,
- _dbus_string_get_length (&str)))
+ if (_dbus_validate_signature_with_reason (&str, 0,
+ _dbus_string_get_length (&str)) != DBUS_VALID)
{
- _dbus_warn ("Signature \"%s\" should have been valid", valid_signatures[i]);
+ _dbus_warn ("Signature \"%s\" should have been valid and OOM should not have occurred", valid_signatures[i]);
_dbus_assert_not_reached ("invalid signature");
}
i = 0;
while (i < (int) _DBUS_N_ELEMENTS (invalid_signatures))
{
+ DBusValidity validity;
+
_dbus_string_init_const (&str, invalid_signatures[i]);
- if (_dbus_validate_signature (&str, 0,
- _dbus_string_get_length (&str)))
+ validity = _dbus_validate_signature_with_reason (&str, 0,
+ _dbus_string_get_length (&str));
+
+ /* Validity values less than DBUS_VALID are OOM or unknown validity.
+ * TODO: specify in which way each one should be invalid */
+ if (validity <= DBUS_VALID)
{
- _dbus_warn ("Signature \"%s\" should have been invalid", invalid_signatures[i]);
+ _dbus_warn ("Signature \"%s\" should have been invalid and OOM should not have occurred", invalid_signatures[i]);
_dbus_assert_not_reached ("valid signature");
}
if (_dbus_validate_member (&str, 0, 4))
_dbus_assert_not_reached ("validated too-long string");
- _dbus_string_init_const (&str, "sss");
- if (_dbus_validate_signature (&str, 0, 4))
- _dbus_assert_not_reached ("validated too-long signature");
-
/* Validate string exceeding max name length */
if (!_dbus_string_init (&str))
_dbus_assert_not_reached ("no memory");
return _dbus_validate_bus_name_full (str, start, len, TRUE);
}
-/**
- * Checks that the given range of the string is a valid message type
- * signature in the D-Bus protocol.
- *
- * @todo this is inconsistent with most of DBusString in that
- * it allows a start,len range that extends past the string end.
- *
- * @param str the string
- * @param start first byte index to check
- * @param len number of bytes to check
- * @returns #TRUE if the byte range exists and is a valid signature
- */
-dbus_bool_t
-_dbus_validate_signature (const DBusString *str,
- int start,
- int len)
-{
- _dbus_assert (start >= 0);
- _dbus_assert (start <= _dbus_string_get_length (str));
- _dbus_assert (len >= 0);
-
- if (len > _dbus_string_get_length (str) - start)
- return FALSE;
-
- return _dbus_validate_signature_with_reason (str, start, len) == DBUS_VALID;
-}
-
/** define _dbus_check_is_valid_path() */
DEFINE_DBUS_NAME_CHECK(path)
/** define _dbus_check_is_valid_interface() */
dbus_bool_t _dbus_validate_bus_namespace (const DBusString *str,
int start,
int len);
-DBUS_PRIVATE_EXPORT
-dbus_bool_t _dbus_validate_signature (const DBusString *str,
- int start,
- int len);
/* just to have a name consistent with the above: */
#define _dbus_validate_utf8(s,b,e) _dbus_string_validate_utf8 (s, b, e)