[glib: 4/5] gdbusaddress: Validate the noncefile attribute of nonce-tcp addresses
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 4/5] gdbusaddress: Validate the noncefile attribute of nonce-tcp addresses
- Date: Wed, 9 Oct 2019 12:33:35 +0000 (UTC)
commit 8492df9f342ee27207b34fdfda9b3d9a83073bda
Author: Philip Withnall <withnall endlessm com>
Date: Tue Oct 8 13:52:13 2019 +0100
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>
gio/gdbusaddress.c | 12 ++++++++++--
gio/tests/gdbus-addresses.c | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 3b0f369d8..6958d7cc6 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -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);
diff --git a/gio/tests/gdbus-addresses.c b/gio/tests/gdbus-addresses.c
index 173383d83..26c21ee24 100644
--- a/gio/tests/gdbus-addresses.c
+++ b/gio/tests/gdbus-addresses.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]