From afc25c5241b5e4c8232ee737f31b6b5e27b57604 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakob.olsson@iopsys.eu> Date: Wed, 21 May 2025 12:42:31 +0200 Subject: [PATCH] dynbhd: use base 10 for stroul when reading mid --- src/dynbh/dynbh.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/dynbh/dynbh.c b/src/dynbh/dynbh.c index f89090e5..36f323ed 100644 --- a/src/dynbh/dynbh.c +++ b/src/dynbh/dynbh.c @@ -186,10 +186,8 @@ static void bridge_readd(atimer_t *t) /* callback to send ap autoconfig search */ static void send_apconf_cb(atimer_t *t) { - struct ethport *ap = container_of(t, struct ethport, - send_apconf); + struct ethport *ap = container_of(t, struct ethport, send_apconf); char mid[16] = {0}; - char *endptr = NULL; fprintf(stderr, "|%s:%d| sending query num %d for ifname:%s alid:%s \n", __func__, __LINE__, (ap->num_mid+1), ap->ifname, ap->ctx->alidstr); runCmd("[ -n \"$(ubus list ieee1905.al.%s)\" ] || ubus call ieee1905 add_interface '{\"ifname\":\"%s\"}'", ap->ifname, ap->ifname); @@ -201,12 +199,12 @@ ubus call ieee1905 cmdu '{"ifname":"eth0", "dst":"01:80:C2:00:00:13", "type":7, runCmd("ubus list ieee1905.al.%s", ap->ifname); fprintf(stderr, "mid = %s\n", mid); errno = 0; - ap->mid[ap->num_mid] = (uint16_t) strtol(mid, &endptr, 16); - if (errno || *endptr != '\0') { + ap->mid[ap->num_mid] = (uint16_t) strtoul(mid, NULL, 10); + if (errno) { fprintf(stderr, "Invalid mid value: %s\n", mid); ap->mid[ap->num_mid] = 0; } - fprintf(stderr, "mid[%d] = %d\n", ap->num_mid, ap->mid[ap->num_mid]); + fprintf(stderr, "mid[%d] = %u\n", ap->num_mid, ap->mid[ap->num_mid]); if (ap->num_mid < 31) ap->num_mid++; -- GitLab