public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: Fix signedness problem in parse_gw_bandwidth
Date: Sat,  4 Jun 2011 14:00:49 +0200	[thread overview]
Message-ID: <1307188849-20156-1-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <201106041359.15552.sven@narfation.org>

strict_strtoul as used in parse_gw_bandwidth is defined for unsigned
long and strict_strtol should be used instead for long.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Added compat.h helper function

 compat.h         |   10 ++++++++++
 gateway_common.c |    4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compat.h b/compat.h
index 0f0e66e..66a8adc 100644
--- a/compat.h
+++ b/compat.h
@@ -104,6 +104,16 @@ static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
 	ret; \
 })
 
+#define strict_strtol(cp, base, res) \
+	({ \
+	int ret = 0; \
+	char *endp; \
+	*res = simple_strtol(cp, &endp, base); \
+	if (cp == endp) \
+		ret = -EINVAL; \
+	ret; \
+})
+
 #define to_battr(a) container_of(a, struct bat_attribute, attr)
 
 ssize_t bat_wrapper_show(struct kobject *kobj, struct attribute *attr,
diff --git a/gateway_common.c b/gateway_common.c
index ed3bd36..e74307b 100644
--- a/gateway_common.c
+++ b/gateway_common.c
@@ -97,7 +97,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 			*tmp_ptr = '\0';
 	}
 
-	ret = strict_strtoul(buff, 10, &ldown);
+	ret = strict_strtol(buff, 10, &ldown);
 	if (ret) {
 		bat_err(net_dev,
 			"Download speed of gateway mode invalid: %s\n",
@@ -122,7 +122,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 				*tmp_ptr = '\0';
 		}
 
-		ret = strict_strtoul(slash_ptr + 1, 10, &lup);
+		ret = strict_strtol(slash_ptr + 1, 10, &lup);
 		if (ret) {
 			bat_err(net_dev,
 				"Upload speed of gateway mode invalid: "
-- 
1.7.5.3


  reply	other threads:[~2011-06-04 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-04 10:40 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Don't return value in void function Sven Eckelmann
2011-06-04 10:40 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Fix signedness problem in parse_gw_bandwidth Sven Eckelmann
2011-06-04 11:44   ` Marek Lindner
2011-06-04 11:59     ` Sven Eckelmann
2011-06-04 12:00       ` Sven Eckelmann [this message]
2011-06-05 20:35         ` [B.A.T.M.A.N.] [PATCHv2 " Marek Lindner
2011-06-05 20:33 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Don't return value in void function Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307188849-20156-1-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox