ptserver: Avoid inet_ntoa

The ptserver uses inet_ntoa in a few places, such as for calculating
host CPS. This isn't safe in pthreaded environments, so use
afs_inet_ntoa_r instead.

Reviewed-on: http://gerrit.openafs.org/8287
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
(cherry picked from commit 527f2ba00c1247ae7e8d6f355572c8635331bc0c)

Change-Id: I3740a294bd93b000842ccd791f2a11cef5092a9a
Reviewed-on: http://gerrit.openafs.org/8546
Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
This commit is contained in:
Andrew Deason 2012-10-23 15:47:06 -05:00 committed by Paul Smeddle
parent 3ce1c5394f
commit a9b0f975f6

View File

@ -1244,6 +1244,7 @@ getCPS2(struct rx_call *call, afs_int32 aid, afs_uint32 ahost, prlist *alist,
afs_int32 hostid; afs_int32 hostid;
int host_list = 0; int host_list = 0;
struct in_addr iaddr; struct in_addr iaddr;
char hoststr[16];
*over = 0; *over = 0;
iaddr.s_addr = ntohl(ahost); iaddr.s_addr = ntohl(ahost);
@ -1276,7 +1277,7 @@ getCPS2(struct rx_call *call, afs_int32 aid, afs_uint32 ahost, prlist *alist,
|| !AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY)) || !AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
ABORT_WITH(tt, PRPERM); ABORT_WITH(tt, PRPERM);
} }
code = NameToID(tt, inet_ntoa(iaddr), &hostid); code = NameToID(tt, afs_inet_ntoa_r(iaddr.s_addr, hoststr), &hostid);
if (code == PRSUCCESS && hostid != 0) { if (code == PRSUCCESS && hostid != 0) {
temp = FindByID(tt, hostid); temp = FindByID(tt, hostid);
if (temp) { if (temp) {
@ -1323,6 +1324,7 @@ getHostCPS(struct rx_call *call, afs_uint32 ahost, prlist *alist,
struct prentry host_tentry; struct prentry host_tentry;
afs_int32 hostid; afs_int32 hostid;
struct in_addr iaddr; struct in_addr iaddr;
char hoststr[16];
*over = 0; *over = 0;
iaddr.s_addr = ntohl(ahost); iaddr.s_addr = ntohl(ahost);
@ -1341,7 +1343,7 @@ getHostCPS(struct rx_call *call, afs_uint32 ahost, prlist *alist,
if (code) if (code)
ABORT_WITH(tt, code); ABORT_WITH(tt, code);
code = NameToID(tt, inet_ntoa(iaddr), &hostid); code = NameToID(tt, afs_inet_ntoa_r(iaddr.s_addr, hoststr), &hostid);
if (code == PRSUCCESS && hostid != 0) { if (code == PRSUCCESS && hostid != 0) {
temp = FindByID(tt, hostid); temp = FindByID(tt, hostid);
if (temp) { if (temp) {
@ -2117,11 +2119,12 @@ addWildCards(struct ubik_trans *tt, prlist *alist, afs_uint32 host)
afs_int32 hostid; afs_int32 hostid;
int size = 0, i, code; int size = 0, i, code;
int added = 0; int added = 0;
char hoststr[16];
while ((host = (host & wild))) { while ((host = (host & wild))) {
wild = htonl(ntohl(wild) << 8); wild = htonl(ntohl(wild) << 8);
iaddr.s_addr = host; iaddr.s_addr = host;
code = NameToID(tt, inet_ntoa(iaddr), &hostid); code = NameToID(tt, afs_inet_ntoa_r(iaddr.s_addr, hoststr), &hostid);
if (code == PRSUCCESS && hostid != 0) { if (code == PRSUCCESS && hostid != 0) {
temp = FindByID(tt, hostid); temp = FindByID(tt, hostid);
if (temp) { if (temp) {