Patchwork [6/7] libxt_LED: guard against negative numbers

login
register
mail settings
Submitter Jan Engelhardt
Date July 28, 2012, 5:21 p.m.
Message ID <1343496069-5442-7-git-send-email-jengelh@inai.de>
Download mbox | patch
Permalink /patch/173882/
State Accepted
Headers show

Comments

Jan Engelhardt - July 28, 2012, 5:21 p.m.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
 extensions/libxt_LED.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Patch

diff --git a/extensions/libxt_LED.c b/extensions/libxt_LED.c
index 9d68fa2..e6cf849 100644
--- a/extensions/libxt_LED.c
+++ b/extensions/libxt_LED.c
@@ -49,6 +49,7 @@  static void LED_help(void)
 static void LED_parse(struct xt_option_call *cb)
 {
 	struct xt_led_info *led = cb->data;
+	unsigned int delay;
 
 	xtables_option_parse(cb);
 	switch (cb->entry->id) {
@@ -59,8 +60,10 @@  static void LED_parse(struct xt_option_call *cb)
 	case O_LED_DELAY:
 		if (strncasecmp(cb->arg, "inf", 3) == 0)
 			led->delay = -1;
-		else
-			led->delay = strtoul(cb->arg, NULL, 0);
+		else if (!xtables_strtoui(cb->arg, NULL, &delay, 0, UINT32_MAX))
+			xtables_error(PARAMETER_PROBLEM,
+				"Delay value must be within range 0..%u",
+				UINT32_MAX);
 		break;
 	case O_LED_ALWAYS_BLINK:
 		led->always_blink = 1;