|
|
893260 |
From 4bbfd43121e4c1f59074b1b0def9804c1890b2dc Mon Sep 17 00:00:00 2001
|
|
|
893260 |
From: Jan Macku <jamacku@redhat.com>
|
|
|
893260 |
Date: Mon, 19 Jul 2021 09:48:19 +0200
|
|
|
893260 |
Subject: [PATCH] review of CWE-170, CWE-772
|
|
|
893260 |
|
|
|
893260 |
Resolves: #1938887
|
|
|
893260 |
---
|
|
|
893260 |
libsupp/clif.c | 2 ++
|
|
|
893260 |
traceroute/traceroute.c | 7 ++++++-
|
|
|
893260 |
2 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
893260 |
|
|
|
893260 |
diff --git a/libsupp/clif.c b/libsupp/clif.c
|
|
|
893260 |
index 4ef20e4..60ec291 100644
|
|
|
893260 |
--- a/libsupp/clif.c
|
|
|
893260 |
+++ b/libsupp/clif.c
|
|
|
893260 |
@@ -229,10 +229,12 @@ static void err_bad_arg (const CLIF_option *optn, char c, int n) {
|
|
|
893260 |
|
|
|
893260 |
if (c) {
|
|
|
893260 |
s = show_short (&tmp); /* always without arg... */
|
|
|
893260 |
+ /* coverity[buffer_size_warning] - not a bug, s ends with '\0', see line 97 */
|
|
|
893260 |
strncpy (ss, s, sizeof (ss));
|
|
|
893260 |
s = show_short (optn);
|
|
|
893260 |
} else {
|
|
|
893260 |
s = show_long (&tmp); /* always without arg... */
|
|
|
893260 |
+ /* coverity[buffer_size_warning] - not a bug, s ends with '\0', see line 97 */
|
|
|
893260 |
strncpy (ss, s, sizeof (ss));
|
|
|
893260 |
s = show_long (optn);
|
|
|
893260 |
}
|
|
|
893260 |
diff --git a/traceroute/traceroute.c b/traceroute/traceroute.c
|
|
|
893260 |
index 4be9b24..0a29e36 100644
|
|
|
893260 |
--- a/traceroute/traceroute.c
|
|
|
893260 |
+++ b/traceroute/traceroute.c
|
|
|
893260 |
@@ -217,8 +217,12 @@ static int getaddr (const char *name, sockaddr_any *addr) {
|
|
|
893260 |
}
|
|
|
893260 |
if (!ai) ai = res; /* anything... */
|
|
|
893260 |
|
|
|
893260 |
- if (ai->ai_addrlen > sizeof (*addr))
|
|
|
893260 |
+ if (ai->ai_addrlen > sizeof (*addr)) {
|
|
|
893260 |
+ /* Avoid of leaking res (CWE-772) */
|
|
|
893260 |
+ freeaddrinfo (res);
|
|
|
893260 |
return -1; /* paranoia */
|
|
|
893260 |
+ }
|
|
|
893260 |
+
|
|
|
893260 |
memcpy (addr, ai->ai_addr, ai->ai_addrlen);
|
|
|
893260 |
|
|
|
893260 |
freeaddrinfo (res);
|
|
|
893260 |
@@ -244,6 +248,7 @@ static void make_fd_used (int fd) {
|
|
|
893260 |
close (nfd);
|
|
|
893260 |
}
|
|
|
893260 |
|
|
|
893260 |
+ /* coverity[leaked_handle] - not a bug, see line 665 */
|
|
|
893260 |
return;
|
|
|
893260 |
}
|
|
|
893260 |
|
|
|
893260 |
--
|
|
|
893260 |
2.31.1
|
|
|
893260 |
|