Check for truncated source address when receiving packets

This commit is contained in:
Miroslav Lichvar 2014-08-15 12:54:32 +02:00
parent 192f74f0a1
commit ff4abc69c3
2 changed files with 6 additions and 0 deletions

View file

@ -1644,6 +1644,9 @@ read_from_cmd_socket(void *anything)
return; return;
} }
if (from_length > sizeof (where_from))
LOG_FATAL(LOGF_CmdMon, "Truncated source address");
read_length = status; read_length = status;
LCL_ReadRawTime(&now); LCL_ReadRawTime(&now);

View file

@ -481,6 +481,9 @@ read_from_socket(void *anything)
reponse on a subsequent recvfrom). */ reponse on a subsequent recvfrom). */
if (status > 0) { if (status > 0) {
if (msg.msg_namelen > sizeof (where_from))
LOG_FATAL(LOGF_NtpIO, "Truncated source address");
switch (where_from.u.sa_family) { switch (where_from.u.sa_family) {
case AF_INET: case AF_INET:
remote_addr.ip_addr.family = IPADDR_INET4; remote_addr.ip_addr.family = IPADDR_INET4;