linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
Subject: [PATCH v3 4/6] i2cset: Ensure that there is no junk after the command/mode parameter
Date: Mon, 14 Feb 2011 10:06:11 -0800	[thread overview]
Message-ID: <1297706773-26389-5-git-send-email-guenter.roeck@ericsson.com> (raw)
In-Reply-To: <1297706773-26389-1-git-send-email-guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>

Since the value mask can no longer be set after the mode command,
we can make sure that there is no junk after the command/mode
parameter in the command line.

Signed-off-by: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
---
 CHANGES        |    1 +
 tools/i2cset.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/CHANGES b/CHANGES
index 999ff26..1ffe18f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ SVN
   i2c-dev.h: Make value arrays const for block write functions
   i2cset: Add support for SMBus and I2C block writes
           Remove obsolete means to specify value mask
+          More stringent parameter validation
 
 3.0.3 (2010-12-12)
   Makefile: Let the environment set CC and CFLAGS
diff --git a/tools/i2cset.c b/tools/i2cset.c
index 7750c03..a45a829 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -240,6 +240,9 @@ int main(int argc, char *argv[])
 				block[len] = value;
 			}
 			goto dofile;
+		} else if (argc != flags + 6) {
+			fprintf(stderr, "Error: Too many arguments!\n");
+			help();
 		}
 	}
 
-- 
1.7.0.4

  parent reply	other threads:[~2011-02-14 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-14 18:06 [PATCH v3 0/6] i2cset changes Guenter Roeck
     [not found] ` <1297706773-26389-1-git-send-email-guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
2011-02-14 18:06   ` [PATCH v2 1/6] i2cset: Remove deprecated method to provide the value mask Guenter Roeck
2011-02-14 18:06   ` [PATCH v3 2/6] i2cset: Check number of arguments for block data writes Guenter Roeck
2011-02-14 18:06   ` [PATCH v2 3/6] i2cset: Abort if value mask is set for block commands Guenter Roeck
2011-02-14 18:06   ` Guenter Roeck [this message]
2011-02-14 18:06   ` [PATCH v2 5/6] i2cset: Get command/mode before reading data Guenter Roeck
2011-02-14 18:06   ` [PATCH v3 6/6] i2cset: Check range for data value mask Guenter Roeck
2011-02-15  9:45   ` [PATCH v3 0/6] i2cset changes Jean Delvare

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=1297706773-26389-5-git-send-email-guenter.roeck@ericsson.com \
    --to=guenter.roeck-izefyvvap7pwk0htik3j/w@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).