infiniband-diags: ibstat fix strncpy coverity check and -l bug
PATCH 1/1 infiniband-diags: ibstat fix strncpy coverity check and -l bug
--- src/ibstat.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
src/ibstat.c +2 -7
@@ -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) { -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]);
Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20130612170307.8eb7f51c4b68512db703615a-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
On 6/12/2013 8:03 PM, Ira Weiny wrote:
This seems like 2 different patches to me.
Quoted 20 lines
Signed-off-by Ira Weiny <[email protected]>--- src/ibstat.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)src/ibstat.c +2
-1@@ -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 ; }
src/ibstat.c int main(int argc, char *argv[]) · line 327
Quoted 4 lines
src/ibstat.c +0
-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
src/ibstat.c int main(int argc, char *argv[]) · line 330
Quoted 8 lines
src/ibstat.c +0
-5-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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 51B922B2.3020404-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Quoted 3 lines · On Wed, 12 Jun 2013 21:38:58 -0400 Hal Rosenstock…
On 6/12/2013 8:03 PM, Ira Weiny wrote:
This seems like 2 different patches to me.
Not really...
Quoted 10 lines
Quoted 10 lines
Signed-off-by Ira Weiny <[email protected]>--- src/ibstat.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)src/ibstat.c +0
-0@@ -324,12 +325,6 @@ int main(int argc, char *argv[])return 0 ; }
Quoted 8 lines
src/ibstat.c int main(int argc, char *argv[]) · line 327
Quoted 1 line
src/ibstat.c +0
-1-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.
V2 on the way. I think we should still get rid of that if clause but your right I broke the "port" parameter.
Ira
Quoted 12 lines
-- Hal
Quoted 8 lines
src/ibstat.c +0
-5-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]);
Signature · 5 lines
Ira Weiny <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html