[PATCH] cifscreds: check optind before accessing argv[optind]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Redhat bugzilla: 1278543

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

Signed-off-by: Ronnie Sahlberg <lsahlber@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux