From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hal Rosenstock Subject: Re: [PATCH] infiniband-diags: ibstat fix strncpy coverity check and -l bug Date: Wed, 12 Jun 2013 21:38:58 -0400 Message-ID: <51B922B2.3020404@dev.mellanox.co.il> References: <20130612170307.8eb7f51c4b68512db703615a@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130612170307.8eb7f51c4b68512db703615a-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ira Weiny Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Dan Ben Yosef List-Id: linux-rdma@vger.kernel.org On 6/12/2013 8:03 PM, Ira Weiny wrote: This seems like 2 different patches to me. > Signed-off-by: Ira Weiny > --- > src/ibstat.c | 9 ++------- > 1 files changed, 2 insertions(+), 7 deletions(-) > > diff --git a/src/ibstat.c b/src/ibstat.c > index 665bb0a..1ef27f2 100644 > --- a/src/ibstat.c > +++ b/src/ibstat.c > @@ -314,7 +314,8 @@ int main(int argc, char *argv[]) > if (i >= n) > IBPANIC("'%s' IB device can't be found", argv[0]); > > - strncpy(names[i], argv[0], sizeof names[i]); > + strncpy(names[0], argv[0], sizeof(names[0])-1); > + names[0][sizeof(names[0])-1] = '\0'; > n = 1; > } > > @@ -324,12 +325,6 @@ int main(int argc, char *argv[]) > return 0; > } > > - if (!list_only && argc) { I think I see the issue. Rather than eliminate this if clause, I think the line above should be: if (!list_only && argc > 1) { so that this properly handles the case when the port option is supplied. -- Hal > - if (ca_stat(argv[0], dev_port, short_format) < 0) > - IBPANIC("stat of IB device '%s' failed", argv[0]); > - return 0; > - } > - > for (i = 0; i < n; i++) { > if (list_only) > printf("%s\n", names[i]); -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html