summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcom_socket.c
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2017-10-26 16:12:04 -0400
committerChris Luke <chris_luke@comcast.com>2017-10-26 21:25:26 +0000
commitfaf9d7730828b80814a233eeecf7affc046193d3 (patch)
tree8d2dbf8c03b9fc117ba4c42f897c43cda7997d64 /src/vcl/vcom_socket.c
parent617dffaee47fc6fbc0dca85dc07c53ca9b57bf90 (diff)
VCL-LDPRELOAD: Fix more coverity warnings
vcom.c: CID 178227: Logically dead code in vcom.c vcom_socket.c: CID 178254: Dereference after null check CID 178250: Out-of-bounds access vppcom.c: CID 178252: Unused value Suppress vppcom_session_attr() debug output. Change-Id: I1d47bafb84fc0ad00c642392ae3cb6761fd3fb17 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/vcl/vcom_socket.c')
-rw-r--r--src/vcl/vcom_socket.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/vcl/vcom_socket.c b/src/vcl/vcom_socket.c
index 6ce15148d21..5918f6b73d1 100644
--- a/src/vcl/vcom_socket.c
+++ b/src/vcl/vcom_socket.c
@@ -1607,10 +1607,11 @@ vcom_session_recvfrom (int __sid, void *__restrict __buf, size_t __n,
{
int rv;
vppcom_endpt_t ep;
+ u8 src_addr[sizeof (struct sockaddr_in6)];
if (__addr)
{
- ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
+ ep.ip = src_addr;
rv = vppcom_session_recvfrom (__sid, __buf, __n, __flags, &ep);
if (rv > 0)
@@ -1623,16 +1624,22 @@ vcom_session_recvfrom (int __sid, void *__restrict __buf, size_t __n,
{
case AF_INET:
((struct sockaddr_in *) __addr)->sin_port = ep.port;
+ memcpy (&((struct sockaddr_in *) __addr)->sin_addr,
+ src_addr, sizeof (struct in_addr));
+
*__addr_len = sizeof (struct sockaddr_in);
break;
case AF_INET6:
((struct sockaddr_in6 *) __addr)->sin6_port = ep.port;
+ memcpy (((struct sockaddr_in6 *) __addr)->sin6_addr.
+ __in6_u.__u6_addr8, src_addr,
+ sizeof (struct in6_addr));
*__addr_len = sizeof (struct sockaddr_in6);
break;
default:
- rv = -1;
+ rv = -EAFNOSUPPORT;
break;
}
}
@@ -1826,6 +1833,9 @@ vcom_socket_getsockopt (int __fd, int __level, int __optname,
uword *p;
vcom_socket_t *vsock;
+ if (!__optval || !__optlen)
+ return -EINVAL;
+
p = hash_get (vsm->sockidx_by_fd, __fd);
if (!p)
return -EBADF;
@@ -1837,9 +1847,6 @@ vcom_socket_getsockopt (int __fd, int __level, int __optname,
if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
return -EINVAL;
- if (!__optval && !__optlen)
- return -EFAULT;
-
switch (__level)
{
case SOL_SOCKET: