gdbusaddress: Validate the noncefile attribute of nonce-tcp addresses

Doing this mostly to fix a compiler warning about tautological
assignments on Android.

See the D-Bus specification:
https://dbus.freedesktop.org/doc/dbus-specification.html#transports-nonce-tcp-sockets

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-10-08 13:52:13 +01:00
parent e99003841a
commit 8492df9f34
2 changed files with 11 additions and 2 deletions

View File

@ -265,9 +265,17 @@ is_valid_nonce_tcp (const gchar *address_entry,
/* TODO: validate host */
}
nonce_file = nonce_file; /* To avoid -Wunused-but-set-variable */
if (nonce_file != NULL && *nonce_file == '\0')
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Error in address “%s” — the “%s” attribute is malformed"),
address_entry, "noncefile");
goto out;
}
ret= TRUE;
ret = TRUE;
out:
g_list_free (keys);

View File

@ -146,6 +146,7 @@ test_nonce_tcp_address (void)
assert_not_supported_address ("nonce-tcp:host=localhost,port=420000");
assert_not_supported_address ("nonce-tcp:host=localhost,port=42x");
assert_not_supported_address ("nonce-tcp:host=localhost,port=");
assert_not_supported_address ("nonce-tcp:host=localhost,port=42,noncefile=");
}
static void