Skip to content

Commit 5717eb0

Browse files
committed
runtime: don't change string in place
Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
1 parent 065130e commit 5717eb0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/rposix.r

+5-3
Original file line numberDiff line numberDiff line change
@@ -1259,17 +1259,19 @@ int sock_listen(char *addr, int is_udp_or_listener, int af_fam)
12591259

12601260

12611261
if ((s = sock_get(addr)) < 0) {
1262-
char *p;
1262+
char *p, fname[BUFSIZ];
12631263

12641264
/*
12651265
* If the first argument is just a name, it's a unix domain socket.
12661266
* If there's a : then it's host:port except if the host part is
12671267
* empty, it means on any interface.
12681268
*/
12691269
1270-
if ((p=strrchr(addr, ':')) != NULL) {
1270+
SAFE_strncpy(fname,addr, sizeof(fname));
1271+
1272+
if ((p=strrchr(fname, ':')) != NULL) {
12711273
*p = 0;
1272-
res0 = uni_getaddrinfo(addr, p+1, is_udp_or_listener == 1, af_fam);
1274+
res0 = uni_getaddrinfo(fname, p+1, is_udp_or_listener == 1, af_fam);
12731275
*p = ':';
12741276
12751277
if (!res0)

0 commit comments

Comments
 (0)