diff mbox series

client: fix crash from unknown properties

Message ID 20220628215739.2332211-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series client: fix crash from unknown properties | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make FAIL: client/dbus-proxy.c: In function 'proxy_interface_property_tostr': client/dbus-proxy.c:90:17: error: 'return' with no value, in function returning non-void [-Werror=return-type] 90 | return; | ^~~~~~ client/dbus-proxy.c:81:20: note: declared here 81 | static const void *proxy_interface_property_tostr( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2384: client/dbus-proxy.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1571: all] Error 2
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: client/dbus-proxy.c: In function ‘proxy_interface_property_tostr’: client/dbus-proxy.c:90:17: error: ‘return’ with no value, in function returning non-void [-Werror=return-type] 90 | return; | ^~~~~~ client/dbus-proxy.c:81:20: note: declared here 81 | static const void *proxy_interface_property_tostr( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2383: client/dbus-proxy.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1570: all] Error 2
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: client/dbus-proxy.c:90:3: error: non-void function 'proxy_interface_property_tostr' should return a value [-Wreturn-type] return; ^ 1 error generated. make[1]: *** [Makefile:2383: client/dbus-proxy.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1570: all] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-ci-makecheck pending makecheck SKIP

Commit Message

James Prestwood June 28, 2022, 9:57 p.m. UTC
The dbus proxy code assumes that every interface has a set of
properties registered in a 'proxy_interface_property' structure,
assuming the interface has any properties at all. If the interface
is assumed to have no properties (and no property table) but
actually does, the property table lookup fails but is assumed to
have succeeded and causes a crash.

This caused iwctl to crash after some properties were added to DPP
since the DPP interface previously had no properties.

Now, check that the property table was valid before accessing it. This
should allow properties to be added to new interfaces without crashing
older versions of iwctl.
---
 client/dbus-proxy.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Denis Kenzior June 28, 2022, 10:49 p.m. UTC | #1
Hi James,

On 6/28/22 16:57, James Prestwood wrote:
> The dbus proxy code assumes that every interface has a set of
> properties registered in a 'proxy_interface_property' structure,
> assuming the interface has any properties at all. If the interface
> is assumed to have no properties (and no property table) but
> actually does, the property table lookup fails but is assumed to
> have succeeded and causes a crash.
> 
> This caused iwctl to crash after some properties were added to DPP
> since the DPP interface previously had no properties.
> 
> Now, check that the property table was valid before accessing it. This
> should allow properties to be added to new interfaces without crashing
> older versions of iwctl.
> ---
>   client/dbus-proxy.c | 3 +++
>   1 file changed, 3 insertions(+)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
index 0373a3df..624ce4aa 100644
--- a/client/dbus-proxy.c
+++ b/client/dbus-proxy.c
@@ -107,6 +107,9 @@  static void proxy_interface_property_update(struct proxy_interface *proxy,
 	const struct proxy_interface_property *property_table =
 							proxy->type->properties;
 
+	if (!property_table)
+		return;
+
 	for (i = 0; property_table[i].name; i++) {
 		if (strcmp(property_table[i].name, name))
 			continue;