Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] cifscreds: check optind before accessing argv[optind]
@ 2018-01-23  0:48 Ronnie Sahlberg
       [not found] ` <CAH2r5ms-rpxf5E_XZc1W+h1tMmV26WEbXWCxEfYa+cA7PX-VTw@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Ronnie Sahlberg @ 2018-01-23  0:48 UTC (permalink / raw)
  To: linux-cifs; +Cc: Pavel Shilovsky

Redhat bugzilla: 1278543

This fixes a segfault for some incorrect usage, for example
   cifscreds -u test

Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-23  0:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-23  0:48 [PATCH] cifscreds: check optind before accessing argv[optind] Ronnie Sahlberg
     [not found] ` <CAH2r5ms-rpxf5E_XZc1W+h1tMmV26WEbXWCxEfYa+cA7PX-VTw@mail.gmail.com>
     [not found]   ` <CAH2r5ms-rpxf5E_XZc1W+h1tMmV26WEbXWCxEfYa+cA7PX-VTw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-23  0:57     ` Ronnie Sahlberg
     [not found]       ` <1836982403.1740018.1516669060551.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-01-23  0:59         ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox