Re: [PATCH] wpa_supplicant: If empty bytearray sent via DBUS use default value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 22, 2019 at 09:43:34PM +0200, István Bodnár wrote:
> In case wpa_supplicant receive empty byte array via dbus
> (e.g.: from Network Manager which sends empty private key password field)
> it will use the "NULL" default value.

Why would a string parameter like private_key_passwd be configured as
DBUS_TYPE_ARRAY(DBUS_TYPE_BYTE) instead of DBUS_TYPE_STRING?

It should also be noted that there is a difference between a zero-length
string value ("") and no value set (NULL). If we were to convert
zero-length byte array into NULL, there would be no way of setting an
empty string (""). When setting parameter values over the text-based
control interface, those two cases are separate:
SET_NETWORK 0 field NULL
SET_NETWORK 0 field ""

Based on the actual changes, there may also be some misunderstanding
here on that "default value" part.. Setting a string to NULL (i.e.,
without quotation marks) clears the parameter (sets the C pointer to
NULL) while setting a string to "NULL" (i.e., with quotation marks) sets
the parameter to a string "NULL" (i.e., allocated memory with NULL\0 in
it).

> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -206,17 +206,25 @@ dbus_bool_t set_network_properties(struct
> wpa_supplicant *wpa_s,
>                 value = NULL;
>                 if (entry.type == DBUS_TYPE_ARRAY &&
>                     entry.array_type == DBUS_TYPE_BYTE) {
> -                       if (entry.array_len <= 0)
> +                       if (entry.array_len < 0)
>                                 goto error;

This part might make sense to allow the zero-length value to be set
(and something similar for the DBUS_TYPE_STRING case for
should_quote_opt() cases).

> +                       if (entry.array_len == 0)
> +                               ret = os_snprintf(value, size, "\"%s\"",
> +                                                 "NULL");

This looks quite strange.. This would set the string to "NULL" instead
of removing a previously configured parameter. Was this supposed to be
simply os_snprintf(value, size, "NULL") to get the remove-a-parameter
behavior?

>                 } else if (entry.type == DBUS_TYPE_STRING) {
... this is the case where zero-length string is also rejected. That
should likely remain consistent with the DBUS_TYPE_ARRAY(DBUS_TYPE_BYTE)
case.
 
-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux