as,rsrv: use real client IP instead of untrusted host name
This commit is contained in:
@@ -861,6 +861,14 @@ static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
|
||||
return RSRV_ERROR;
|
||||
}
|
||||
|
||||
/* after all validation */
|
||||
if(asUseIP) {
|
||||
|
||||
DLOG (2, ( "CAS: host_name_action for \"%s\" ignores clist provided host name\n",
|
||||
client->pHostName ) );
|
||||
return RSRV_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* user name will not change if there isnt enough memory
|
||||
*/
|
||||
|
||||
@@ -1421,6 +1421,20 @@ struct client *create_tcp_client (SOCKET sock , const osiSockAddr *peerAddr)
|
||||
}
|
||||
|
||||
client->addr = peerAddr->ia;
|
||||
if(asUseIP) {
|
||||
epicsUInt32 ip = ntohl(client->addr.sin_addr.s_addr);
|
||||
client->pHostName = malloc(24);
|
||||
if(!client->pHostName) {
|
||||
destroy_client ( client );
|
||||
return NULL;
|
||||
}
|
||||
epicsSnprintf(client->pHostName, 24,
|
||||
"%u.%u.%u.%u",
|
||||
(ip>>24)&0xff,
|
||||
(ip>>16)&0xff,
|
||||
(ip>>8)&0xff,
|
||||
(ip>>0)&0xff);
|
||||
}
|
||||
|
||||
/*
|
||||
* see TCP(4P) this seems to make unsolicited single events much
|
||||
|
||||
@@ -86,7 +86,7 @@ typedef struct client {
|
||||
ELLLIST chanList;
|
||||
ELLLIST chanPendingUpdateARList;
|
||||
ELLLIST putNotifyQue;
|
||||
struct sockaddr_in addr;
|
||||
struct sockaddr_in addr; /* peer address, TCP only */
|
||||
epicsTimeStamp time_at_last_send;
|
||||
epicsTimeStamp time_at_last_recv;
|
||||
void *evuser;
|
||||
|
||||
Reference in New Issue
Block a user