From a1015612231e511ef11ecda9c48179a47a1ba980 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 2 Jan 2025 20:11:22 +0000 Subject: [PATCH] auth/factotum: avoid static buffer from netmkaddr() factotum calls authdial() in parallel, so use the reentrant version netmkaddrbuf() instead. --- sys/src/cmd/auth/factotum/util.c | 7 +++++-- sys/src/libauthsrv/authdial.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/src/cmd/auth/factotum/util.c b/sys/src/cmd/auth/factotum/util.c index a37ba4356..ab5ef0a64 100644 --- a/sys/src/cmd/auth/factotum/util.c +++ b/sys/src/cmd/auth/factotum/util.c @@ -75,6 +75,7 @@ netndbauthaddr(void) int _authdial(char *authdom) { + char addr[256]; int i, fd; alarm(30*1000); @@ -97,9 +98,11 @@ _authdial(char *authdom) if(authaddr[0] == nil) netndbauthaddr(); for(i = 0; fd < 0 && authaddr[i] != nil; i++){ - fd = dial(netmkaddr(authaddr[i], "tcp", "567"), 0, 0, 0); + fd = dial(netmkaddrbuf(authaddr[i], "tcp", "567", addr, sizeof(addr)), + nil, nil, nil); if(fd < 0) - fd = dial(netmkaddr(authaddr[i], "il", "566"), 0, 0, 0); + fd = dial(netmkaddrbuf(authaddr[i], "il", "566", addr, sizeof(addr)), + nil, nil, nil); } } alarm(0); diff --git a/sys/src/libauthsrv/authdial.c b/sys/src/libauthsrv/authdial.c index fb67d391c..f8a7c8307 100644 --- a/sys/src/libauthsrv/authdial.c +++ b/sys/src/libauthsrv/authdial.c @@ -7,13 +7,15 @@ int authdial(char *netroot, char *dom) { + char addr[256]; Ndbtuple *t, *nt; char *p; int rv; if(dom == nil) /* look for one relative to my machine */ - return dial(netmkaddr("$auth", nil, "ticket"), nil, nil, nil); + return dial(netmkaddrbuf("$auth", nil, "ticket", addr, sizeof(addr)), + nil, nil, nil); /* look up an auth server in an authentication domain */ p = csgetvalue(netroot, "authdom", dom, "auth", &t); @@ -41,7 +43,8 @@ authdial(char *netroot, char *dom) rv = -1; for(nt = t; nt != nil; nt = nt->entry) { if(strcmp(nt->attr, "auth") == 0) { - rv = dial(netmkaddr(nt->val, nil, "ticket"), nil, nil, nil); + rv = dial(netmkaddrbuf(nt->val, nil, "ticket", addr, sizeof(addr)), + nil, nil, nil); if(rv >= 0) break; }