mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-08-09 09:51:49 +08:00
tun_write(): check input value for sanity
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
This commit is contained in:
+8
-5
@@ -58,11 +58,16 @@ ssize_t tun_write(int sockfd, const void *buf, size_t len)
|
||||
{
|
||||
uint32_t head;
|
||||
const uint8_t *data = buf;
|
||||
uint8_t ip_v = data[0] >> 4;
|
||||
uint8_t ip_v;
|
||||
static int complained;
|
||||
struct iovec iov[2];
|
||||
int ret;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
ip_v = data[0] >> 4;
|
||||
|
||||
if (ip_v == 6)
|
||||
head = htonl(AF_INET6);
|
||||
else if (ip_v == 4)
|
||||
@@ -70,10 +75,8 @@ ssize_t tun_write(int sockfd, const void *buf, size_t len)
|
||||
else {
|
||||
if (!complained) {
|
||||
complained = 1;
|
||||
oc_syslog(
|
||||
LOG_ERR,
|
||||
"tun_write: Unknown packet (len %d) received %02x %02x %02x %02x...",
|
||||
(int)len, data[0], data[1], data[2], data[3]);
|
||||
oc_syslog(LOG_ERR, "tun_write: Unknown packet (len %d)",
|
||||
(int)len);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user