osmtest: Make the "-guid" option's argument mandatory
PATCH 1/1 osmtest: Make the "-guid" option's argument mandatory
From: Roland Dreier <[email protected]>
Currently, the getopt table in osmtest labels the "-guid" option as taking an optional argument; however, running osmtest with the -guid option but no argument just leads to:
$ /usr/sbin/osmtest -guid
Command Line Arguments
Segmentation fault
because the handling for the -guid option just passes optarg directly to strtoull(), and without and argument, optarg is NULL. Really, the argument should be mandatory.
This bug was found by the Mayhem tool:
http://www.forallsecure.com/bug-reports/edea01ceefbb188dcc62b3fc4f59dc743d7429c9/
--- osmtest/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
osmtest/main.c +1 -1
@@ -293,7 +293,7 @@ int main(int argc, char *argv[]) {"wait", 1, NULL, 'w'}, {"inventory", 1, NULL, 'i'}, {"max_lid", 1, NULL, 'm'}, - {"guid", 2, NULL, 'g'}, + {"guid", 1, NULL, 'g'}, {"port", 0, NULL, 'p'}, {"help", 0, NULL, 'h'}, {"stress", 1, NULL, 's'},
Signature · 6 lines
1.8.1.2 -- 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): 1372406820-11505-1-git-send-email-roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Quoted 11 lines · Roland Dreier
From: Roland Dreier <[email protected]>
Currently, the getopt table in osmtest labels the "-guid" option as taking an optional argument; however, running osmtest with the -guid option but no argument just leads to:
$ /usr/sbin/osmtest -guidCommand Line Arguments
Segmentation fault
Quoted 8 lines
because the handling for the -guid option just passes optarg directly to
strtoull(), and without and argument, optarg is NULL. Really, the argument should be mandatory.This bug was found by the Mayhem tool:
http://www.forallsecure.com/bug-reports/edea01ceefbb188dcc62b3fc4f59dc743d7429c9/Signed-off-by Roland Dreier <[email protected]>
Thanks. Applied.
-- Hal
--
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