aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 07:10:30 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commit22ed4467a413961816f317c641e436ca627d06d2 (patch)
tree137ea525b0dee2f196e43faa1eeff585746fce2b /icmp.c
parent6a3f6df865cc8b9626181c87b33b4f7723852a2f (diff)
downloadpasst-22ed4467a413961816f317c641e436ca627d06d2.tar
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.gz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.bz2
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.lz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.xz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.zst
passt-22ed4467a413961816f317c641e436ca627d06d2.zip
treewide: Unchecked return value from library, CWE-252
All instances were harmless, but it might be useful to have some debug messages here and there. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'icmp.c')
-rw-r--r--icmp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/icmp.c b/icmp.c
index 0eb5bfe..8abc94b 100644
--- a/icmp.c
+++ b/icmp.c
@@ -160,6 +160,9 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
if (!ih)
return 1;
+ if (ih->type != ICMP_ECHO && ih->type != ICMP_ECHOREPLY)
+ return 1;
+
sa.sin_port = ih->un.echo.id;
iref.icmp.id = id = ntohs(ih->un.echo.id);
@@ -179,8 +182,9 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
bitmap_set(icmp_act[V4], id);
sa.sin_addr = *(struct in_addr *)addr;
- sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
- (struct sockaddr *)&sa, sizeof(sa));
+ if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
+ (struct sockaddr *)&sa, sizeof(sa)) < 0)
+ debug("ICMP: failed to relay request to socket");
} else if (af == AF_INET6) {
union icmp_epoll_ref iref = { .icmp.v6 = 1 };
struct sockaddr_in6 sa = {
@@ -216,8 +220,9 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
bitmap_set(icmp_act[V6], id);
sa.sin6_addr = *(struct in6_addr *)addr;
- sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
- (struct sockaddr *)&sa, sizeof(sa));
+ if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL,
+ (struct sockaddr *)&sa, sizeof(sa)) < 1)
+ debug("ICMPv6: failed to relay request to socket");
}
return 1;