From: Alexander Aring <alex.aring@gmail.com>
To: Stefan Schmidt <stefan@osg.samsung.com>
Cc: linux-wpan@vger.kernel.org
Subject: Re: [PATCH wpan-tools] mac: range checking for command accepting only 0 or 1
Date: Wed, 19 Aug 2015 16:22:09 +0200 [thread overview]
Message-ID: <20150819142147.GA31917@omega> (raw)
In-Reply-To: <1439993604-8335-1-git-send-email-stefan@osg.samsung.com>
Hi Stefan,
On Wed, Aug 19, 2015 at 04:13:24PM +0200, Stefan Schmidt wrote:
> lbt and ackreq_default only accept 0or 1 as arguments which we did not
> acount for so far. Testing invalid arguments and checking teh return
> code uncovered this one.
>
> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
> ---
> src/mac.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/mac.c b/src/mac.c
> index 76db58f..26c6fc5 100644
> --- a/src/mac.c
> +++ b/src/mac.c
> @@ -175,6 +175,8 @@ static int handle_lbt_mode(struct nl802154_state *state,
> mode = strtoul(argv[0], &end, 0);
> if (*end != '\0')
> return 1;
> + if (mode != 0 && mode != 1)
> + return 1;
>
> NLA_PUT_U8(msg, NL802154_ATTR_LBT_MODE, mode);
>
> @@ -202,6 +204,8 @@ static int handle_ackreq_default(struct nl802154_state *state,
> ackreq = strtoul(argv[0], &end, 0);
> if (*end != '\0')
> return 1;
> + if (ackreq != 0 && ackreq != 1)
> + return 1;
>
range checks should be handled by kernelspace. Currently we do a "!!var"
conversion there. Maybe we should change it there and accept "1" or "0".
We should never handle "if a range is valid or not" inside userspace,
otherwise other applications which talking to nl802154 can do a
different handling then.
- Alex
next prev parent reply other threads:[~2015-08-19 14:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-19 14:13 [PATCH wpan-tools] mac: range checking for command accepting only 0 or 1 Stefan Schmidt
2015-08-19 14:22 ` Alexander Aring [this message]
2015-08-19 14:28 ` Stefan Schmidt
2015-08-19 14:33 ` Alexander Aring
2015-08-19 14:38 ` Alexander Aring
2015-08-19 15:27 ` Stefan Schmidt
2015-08-19 15:58 ` Alexander Aring
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=20150819142147.GA31917@omega \
--to=alex.aring@gmail.com \
--cc=linux-wpan@vger.kernel.org \
--cc=stefan@osg.samsung.com \
/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