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:
signature.asc
Description: PGP signature