summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-05-31 15:27:09 +0000
committerHauke Mehrtens2026-06-07 11:24:33 +0000
commit9dd0055d527d5fee1cb37f8debe28d2762150236 (patch)
tree5c6026749fa8b5f9bf659b5d67c3e453096ddeea
parent0ba47f319b09d02d101b234c2d7c53419b929a7a (diff)
downloaduclient-9dd0055d527d5fee1cb37f8debe28d2762150236.tar.gz
uclient: initialize *port for unknown address families
uclient_get_addr() returned early without writing *port when the address family was neither AF_INET nor AF_INET6. Callers such as the ucode binding's status() pass a pointer and immediately use the result, so for an as-yet-unconnected client (zeroed local/remote_addr) they read and report an uninitialized port value. Set *port to 0 in that case. Assisted-by: Claude:claude-opus-4-8 Link: https://github.com/openwrt/uclient/pull/16 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--uclient.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/uclient.c b/uclient.c
index 915dc55..b9dbf9f 100644
--- a/uclient.c
+++ b/uclient.c
@@ -43,6 +43,8 @@ char *uclient_get_addr(char *dest, int *port, union uclient_addr *a)
portval = a->sin6.sin6_port;
break;
default:
+ if (port)
+ *port = 0;
return strcpy(dest, "Unknown");
}