From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ronnie Sahlberg Subject: [PATCH] cifscreds: check optind before accessing argv[optind] Date: Tue, 23 Jan 2018 11:48:01 +1100 Message-ID: <20180123004801.10182-1-lsahlber@redhat.com> Cc: Pavel Shilovsky To: linux-cifs Return-path: Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Redhat bugzilla: 1278543 This fixes a segfault for some incorrect usage, for example cifscreds -u test 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); -- 2.15.1