52 lines
1.3 KiB
Diff
52 lines
1.3 KiB
Diff
From 97cee02130b395a7c98616b916c9c0e5eae126d4 Mon Sep 17 00:00:00 2001
|
|
From: John Fastabend <john.r.fastabend@intel.com>
|
|
Date: Wed, 27 Jul 2011 15:20:06 -0700
|
|
Subject: [PATCH 20/29] lldptool: better TLV_ID validation
|
|
|
|
Wire up 'strtoul' so that input TLV_ID must be an exact match.
|
|
|
|
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
|
|
Signed-off-by: Petr Sabata <contyk@redhat.com>
|
|
---
|
|
lldptool.c | 10 +++++++---
|
|
1 files changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/lldptool.c b/lldptool.c
|
|
index 26e6d1a..db77a6e 100644
|
|
--- a/lldptool.c
|
|
+++ b/lldptool.c
|
|
@@ -35,6 +35,7 @@
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
#include <ctype.h>
|
|
+#include <errno.h>
|
|
|
|
#include "clif.h"
|
|
#include "lldp_mand_clif.h"
|
|
@@ -437,7 +438,7 @@ static int request(struct clif *clif, int argc, char *argv[])
|
|
int newraw = 0;
|
|
int numargs = 0;
|
|
char **argptr = &argv[0];
|
|
-
|
|
+ char *end;
|
|
int c;
|
|
|
|
memset((void *)&command, 0, sizeof(command));
|
|
@@ -470,8 +471,11 @@ static int request(struct clif *clif, int argc, char *argv[])
|
|
}
|
|
|
|
/* Currently tlvid unset lookup and verify parameter */
|
|
- command.tlvid = strtoul(optarg, (char **) NULL, 0);
|
|
- if (!command.tlvid) {
|
|
+ errno = 0;
|
|
+ command.tlvid = strtoul(optarg, &end, 0);
|
|
+
|
|
+ if (!command.tlvid || errno || *end != '\0' ||
|
|
+ end == optarg) {
|
|
command.tlvid = lookup_tlvid(optarg);
|
|
}
|
|
|
|
--
|
|
1.7.6
|
|
|