|
|
36cfb7 |
From c176919cbf8f11f666c2281785e58fd147ecfea0 Mon Sep 17 00:00:00 2001
|
|
|
36cfb7 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
36cfb7 |
Date: Mon, 29 Apr 2019 20:08:08 +0200
|
|
|
36cfb7 |
Subject: [PATCH] ipntable: Avoid memory allocation for filter.name
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
|
|
|
36cfb7 |
Upstream Status: iproute2.git commit 45c2ec9e95fef
|
|
|
36cfb7 |
|
|
|
36cfb7 |
commit 45c2ec9e95fef8eb6f0807d9a7e5f14c14313c7e
|
|
|
36cfb7 |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
36cfb7 |
Date: Thu Aug 24 11:51:45 2017 +0200
|
|
|
36cfb7 |
|
|
|
36cfb7 |
ipntable: Avoid memory allocation for filter.name
|
|
|
36cfb7 |
|
|
|
36cfb7 |
The original issue was that filter.name might end up unterminated if
|
|
|
36cfb7 |
user provided string was too long. But in fact it is not necessary to
|
|
|
36cfb7 |
copy the commandline parameter at all: just make filter.name point to it
|
|
|
36cfb7 |
instead.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
36cfb7 |
---
|
|
|
36cfb7 |
ip/ipntable.c | 6 +++---
|
|
|
36cfb7 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/ip/ipntable.c b/ip/ipntable.c
|
|
|
36cfb7 |
index ae8c74ead2cb8..2f72c989f35df 100644
|
|
|
36cfb7 |
--- a/ip/ipntable.c
|
|
|
36cfb7 |
+++ b/ip/ipntable.c
|
|
|
36cfb7 |
@@ -37,7 +37,7 @@ static struct
|
|
|
36cfb7 |
int family;
|
|
|
36cfb7 |
int index;
|
|
|
36cfb7 |
#define NONE_DEV (-1)
|
|
|
36cfb7 |
- char name[1024];
|
|
|
36cfb7 |
+ const char *name;
|
|
|
36cfb7 |
} filter;
|
|
|
36cfb7 |
|
|
|
36cfb7 |
static void usage(void) __attribute__((noreturn));
|
|
|
36cfb7 |
@@ -367,7 +367,7 @@ static int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void
|
|
|
36cfb7 |
if (tb[NDTA_NAME]) {
|
|
|
36cfb7 |
const char *name = rta_getattr_str(tb[NDTA_NAME]);
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- if (strlen(filter.name) > 0 && strcmp(filter.name, name))
|
|
|
36cfb7 |
+ if (filter.name && strcmp(filter.name, name))
|
|
|
36cfb7 |
return 0;
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
if (tb[NDTA_PARMS]) {
|
|
|
36cfb7 |
@@ -631,7 +631,7 @@ static int ipntable_show(int argc, char **argv)
|
|
|
36cfb7 |
} else if (strcmp(*argv, "name") == 0) {
|
|
|
36cfb7 |
NEXT_ARG();
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- strncpy(filter.name, *argv, sizeof(filter.name));
|
|
|
36cfb7 |
+ filter.name = *argv;
|
|
|
36cfb7 |
} else
|
|
|
36cfb7 |
invarg("unknown", *argv);
|
|
|
36cfb7 |
|
|
|
36cfb7 |
--
|
|
|
e138d9 |
2.21.0
|
|
|
36cfb7 |
|