X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-nonce.c;h=ef037ef9428343796c5c329c3e75ee8cbb901216;hb=bb8dd7fec5389db4df9b5e8863974149e8a650dc;hp=5143939a2ff198cbdb2ba4492811527d8f0e539a;hpb=99febc2ef8d1a984d4018db2266a5999e2c128a3;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 5143939..ef037ef 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -137,7 +137,8 @@ _dbus_accept_with_noncefile (int listen_fd, const DBusNonceFile *noncefile) DBusString nonce; _dbus_assert (noncefile != NULL); - _dbus_string_init (&nonce); + if (!_dbus_string_init (&nonce)) + return -1; //PENDING(kdab): set better errors if (_dbus_read_nonce (_dbus_noncefile_get_path(noncefile), &nonce, NULL) != TRUE) return -1; @@ -161,7 +162,11 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error) _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_string_init (&nonce); + if (!_dbus_string_init (&nonce)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return FALSE; + } if (!_dbus_generate_random_bytes (&nonce, 16)) { @@ -170,7 +175,7 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error) return FALSE; } - ret = _dbus_string_save_to_file (&nonce, filename, error); + ret = _dbus_string_save_to_file (&nonce, filename, FALSE, error); _dbus_string_free (&nonce); @@ -191,7 +196,6 @@ _dbus_send_nonce (int fd, const DBusString *noncefile, DBusError *error) { dbus_bool_t read_result; int send_result; - size_t sendLen; DBusString nonce; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -235,8 +239,8 @@ do_noncefile_create (DBusNonceFile *noncefile, DBusError *error, dbus_bool_t use_subdir) { - dbus_bool_t ret; DBusString randomStr; + const char *tmp; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -254,8 +258,11 @@ do_noncefile_create (DBusNonceFile *noncefile, goto on_error; } + tmp = _dbus_get_tmpdir (); + if (!_dbus_string_init (&noncefile->dir) - || !_dbus_string_append (&noncefile->dir, _dbus_get_tmpdir())) + || tmp == NULL + || !_dbus_string_append (&noncefile->dir, tmp)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto on_error; @@ -270,7 +277,7 @@ do_noncefile_create (DBusNonceFile *noncefile, } if (!_dbus_string_init (&noncefile->path) || !_dbus_string_copy (&noncefile->dir, 0, &noncefile->path, 0) - || !_dbus_string_append (&noncefile->dir, "/nonce")) + || !_dbus_string_append (&noncefile->path, "/nonce")) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto on_error;