diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2018-01-23 11:48:01 +1100 |
---|---|---|
committer | Pavel Shilovsky <pshilov@microsoft.com> | 2018-03-09 10:44:14 -0800 |
commit | b7eb1124570afa5de9cc511455d00e850fc99c5f (patch) | |
tree | 03f98f8cf26dea8c7e261c1e08be1edf3fa8bad8 | |
parent | b492fe96066a9fec1ce97ce8f1faf10873574a54 (diff) | |
download | cifs-utils-b7eb1124570afa5de9cc511455d00e850fc99c5f.tar.gz cifs-utils-b7eb1124570afa5de9cc511455d00e850fc99c5f.tar.bz2 cifs-utils-b7eb1124570afa5de9cc511455d00e850fc99c5f.zip |
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 <smfrench@gmail.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
-rw-r--r-- | cifscreds.c | 3 |
1 files changed, 3 insertions, 0 deletions
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); |