From b7eb1124570afa5de9cc511455d00e850fc99c5f Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 23 Jan 2018 11:48:01 +1100 Subject: cifscreds: check optind before accessing argv[optind] Redhat bugzilla: 1278543 This fixes a segfault for some incorrect usage, for example cifscreds -u test Reviewed-by: Steve French Signed-off-by: Ronnie Sahlberg --- cifscreds.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cifscreds.c b/cifscreds.c index 5d84c3c..32f2ee4 100644 --- a/cifscreds.c +++ b/cifscreds.c @@ -487,6 +487,9 @@ int main(int argc, char **argv) } } + if (optind >= argc) + return usage(); + /* find the best fit command */ best = NULL; n = strnlen(argv[optind], MAX_COMMAND_SIZE); -- cgit v1.2.3