public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	RDMA mailing list <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH iproute2-next] rdma: Add batch command support
Date: Wed, 21 Feb 2018 18:27:24 +0200	[thread overview]
Message-ID: <20180221162724.GM7709@mtr-leonro.local> (raw)
In-Reply-To: <e9261305-a82e-452d-8da9-07accddfebb4@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

On Wed, Feb 21, 2018 at 09:10:45AM -0700, David Ahern wrote:
> On 2/21/18 5:38 AM, Leon Romanovsky wrote:
> > @@ -36,17 +37,54 @@ static int rd_cmd(struct rd *rd)
> >  		{ 0 }
> >  	};
> >
> > +	rd->argc = argc;
> > +	rd->argv = argv;
> > +
> >  	return rd_exec_cmd(rd, cmds, "object");
> >  }
> >
> > -static int rd_init(struct rd *rd, int argc, char **argv, char *filename)
> > +static int rd_batch(struct rd *rd, const char *name, bool force)
> > +{
> > +	char *line = NULL;
> > +	size_t len = 0;
> > +	int ret = 0;
> > +
> > +	if (name && strcmp(name, "-") != 0) {
> > +		if (!freopen(name, "r", stdin)) {
> > +			pr_err("Cannot open file \"%s\" for reading: %s\n",
> > +			       name, strerror(errno));
> > +			return errno;
> > +		}
> > +	}
> > +
> > +	cmdlineno = 0;
> > +	while (getcmdline(&line, &len, stdin) != -1) {
> > +		char *largv[512];
> > +		int largc;
> > +
> > +		largc = makeargs(line, largv, 100);
>
> you have largv[512] declared but passing a max of 100. I realize other
> batch commands have it hardcoded, but ARRAY_SIZE is better.

Thanks for catching it, it was my copy/paste error.

I'll wait for a day for other comments and will resubmit if it is needed.

The fix is:

diff --git a/rdma/rdma.c b/rdma/rdma.c
index ab8f98d2..ab2c9608 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -62,7 +62,7 @@ static int rd_batch(struct rd *rd, const char *name, bool force)
 		char *largv[512];
 		int largc;

-		largc = makeargs(line, largv, 100);
+		largc = makeargs(line, largv, ARRAY_SIZE(largv));
 		if (!largc)
 			continue;	/* blank line */


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2018-02-21 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 12:38 [PATCH iproute2-next] rdma: Add batch command support Leon Romanovsky
2018-02-21 16:10 ` David Ahern
2018-02-21 16:27   ` Leon Romanovsky [this message]

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=20180221162724.GM7709@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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