[PATCH] WPS: Reconfigure WPS when skip_cred_build or extra_cred parameters are set

Jouni Malinen j at w1.fi
Sun Feb 9 02:56:02 PST 2025


On Mon, Feb 03, 2025 at 12:11:32PM +0100, Quentin Feraboli wrote:
> Allow runtime reconfiguration for skip_cred_build and extra_cred.

> diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
> @@ -1305,6 +1305,9 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
>                 if (ret)

This is whitespace damaged (i.e., tabs converted to spaces) and does not
apply cleanly.

> +               if (os_strcasecmp(cmd, "skip_cred_build") == 0 || os_strcasecmp(cmd, "extra_cred") == 0) {
> +                       hostapd_update_wps(hapd);
> +               }

This needs to be within #ifdef CONFIG_WPS to avoid compilation issues
for builds that do not include WPS functionality.

> diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
> +int wps_registrar_update_extra_cred(struct wps_registrar *reg,
> +                                 int skip_cred_build,
> +                                 const u8 *extra_cred,
> +                                 size_t extra_cred_len)
> +{
> +       if (reg->extra_cred != NULL) {
> +               wpabuf_clear_free(reg->extra_cred);
> +               reg->extra_cred = NULL;
> +       }

No need for that if check for not-NULL.

> +       if (skip_cred_build && extra_cred == NULL) {

!extra_cred is preferred style for checking that a pointer is not NULL.

> +               reg->skip_cred_build = 0;
> +               return -1;

This is something that is not currently enforced for the initial
configuration. Why is this used here?

> +       if (skip_cred_build) {
> +               reg->extra_cred = wpabuf_alloc_copy(extra_cred,
> +                                           extra_cred_len);
> +               if (reg->extra_cred == NULL) {
> +                       reg->skip_cred_build = 0;
> +                       return -1;
> +               }
> +       }
> +
> +       reg->skip_cred_build = skip_cred_build;
> +
> +       return 0;
> +}

What about reg->disable_auto_conf? It is set based on skip_cred_build
and clearing skip_cred_build might imply having to clear
disable_auto_conf as well.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list