*/
#include "dbus-keyring.h"
-#include "dbus-userdb.h"
#include "dbus-protocol.h"
#include <dbus/dbus-string.h>
#include <dbus/dbus-list.h>
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ if (!_dbus_check_dir_is_private_to_user (&keyring->directory, error))
+ return FALSE;
+
if (!_dbus_string_init (&contents))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (&contents);
return FALSE;
}
-
+
keys = NULL;
n_keys = 0;
retval = FALSE;
DBusKey *new;
/* Don't load more than the max. */
- if (n_keys >= (add_new ? MAX_KEYS_IN_FILE : MAX_KEYS_IN_FILE - 1))
+ if (n_keys >= (add_new ? MAX_KEYS_IN_FILE - 1 : MAX_KEYS_IN_FILE))
break;
next = 0;
continue;
}
- if (val > _DBUS_INT_MAX || val < 0)
+ if (val > _DBUS_INT32_MAX || val < 0)
{
_dbus_verbose ("invalid secret key ID at start of line\n");
continue;
if (!add_new_key (&keys, &n_keys, error))
{
_dbus_verbose ("Failed to generate new key: %s\n",
- error ? "(unknown)" : error->message);
+ error ? error->message : "(unknown)");
goto out;
}
if (!_dbus_string_init (&homedir))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return FALSE;
+ return NULL;
}
_dbus_string_init_const (&dotdir, ".dbus-keyrings");
{
_dbus_string_set_length (&homedir, 0);
if (!_dbus_string_append (&homedir, override))
- _dbus_assert_not_reached ("no memory");
+ goto failed;
_dbus_verbose ("Using fake homedir for testing: %s\n",
_dbus_string_get_const_data (&homedir));
if (keyring)
_dbus_keyring_unref (keyring);
_dbus_string_free (&homedir);
- return FALSE;
+ return NULL;
}