Skip to content

Commit

Permalink
runtime: don't change string in place
Browse files Browse the repository at this point in the history
Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
  • Loading branch information
Jafaral committed Feb 26, 2025
1 parent 065130e commit 5717eb0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime/rposix.r
Original file line number Diff line number Diff line change
Expand Up @@ -1259,17 +1259,19 @@ int sock_listen(char *addr, int is_udp_or_listener, int af_fam)


if ((s = sock_get(addr)) < 0) {
char *p;
char *p, fname[BUFSIZ];

/*
* If the first argument is just a name, it's a unix domain socket.
* If there's a : then it's host:port except if the host part is
* empty, it means on any interface.
*/
if ((p=strrchr(addr, ':')) != NULL) {
SAFE_strncpy(fname,addr, sizeof(fname));
if ((p=strrchr(fname, ':')) != NULL) {
*p = 0;
res0 = uni_getaddrinfo(addr, p+1, is_udp_or_listener == 1, af_fam);
res0 = uni_getaddrinfo(fname, p+1, is_udp_or_listener == 1, af_fam);
*p = ':';
if (!res0)
Expand Down

0 comments on commit 5717eb0

Please sign in to comment.