diff options
author | Jouni Malinen <jouni.malinen@atheros.com> | 2009-11-10 18:29:38 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2009-11-10 18:29:38 +0200 |
commit | 68e7cb49b404392a8bc838ec63bb0fa32a1e48f3 (patch) | |
tree | f4bd16aac6ee3a5d1a05bd86d64ddd675ea7412b /wpa_supplicant | |
parent | d69780dcbb049ff00e5a33e974ab7e2025e5a571 (diff) | |
download | external_wpa_supplicant_8_ti-68e7cb49b404392a8bc838ec63bb0fa32a1e48f3.zip external_wpa_supplicant_8_ti-68e7cb49b404392a8bc838ec63bb0fa32a1e48f3.tar.gz external_wpa_supplicant_8_ti-68e7cb49b404392a8bc838ec63bb0fa32a1e48f3.tar.bz2 |
dbus: Use snprintf() and bounds checking instead of strcat()
Better make sure we do not end up writing over the end of the local
registered_sig buffer regardless of how many arguments are used in
dbus method description.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r-- | wpa_supplicant/ctrl_iface_dbus_new_helpers.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/wpa_supplicant/ctrl_iface_dbus_new_helpers.c b/wpa_supplicant/ctrl_iface_dbus_new_helpers.c index 78db812..98414a5 100644 --- a/wpa_supplicant/ctrl_iface_dbus_new_helpers.c +++ b/wpa_supplicant/ctrl_iface_dbus_new_helpers.c @@ -970,22 +970,27 @@ static DBusMessage * get_all_properties( } -static int is_signature_correct(DBusMessage * message, +static int is_signature_correct(DBusMessage *message, struct wpa_dbus_method_desc *method_dsc) { /* According to DBus documentation max length of signature is 255 */ - #define MAX_SIG_LEN 256 - - char registered_sig[MAX_SIG_LEN]; +#define MAX_SIG_LEN 256 + char registered_sig[MAX_SIG_LEN], *pos; const char *sig = dbus_message_get_signature(message); - int i; + int i, ret; - registered_sig[0] = 0; + pos = registered_sig; + *pos = '\0'; for (i = 0; i < method_dsc->args_num; i++) { struct wpa_dbus_argument arg = method_dsc->args[i]; - if (arg.dir == ARG_IN) - strcat(registered_sig, arg.type); + if (arg.dir == ARG_IN) { + size_t blen = registered_sig + MAX_SIG_LEN - pos; + ret = os_snprintf(pos, blen, "%s", arg.type); + if (ret < 0 || (size_t) ret >= blen) + return 0; + pos += ret; + } } return !os_strncmp(registered_sig, sig, MAX_SIG_LEN); |