changeset 1153:67d8a904f5a9

don't silently ignore extra flag arguments
author Matt Johnston <matt@ucc.asn.au>
date Wed, 21 Oct 2015 22:05:50 +0800
parents 57d09741d46d
children b1fabf797bd3
files cli-runopts.c dbclient.1 dropbear.8 svr-runopts.c
diffstat 4 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cli-runopts.c	Tue Sep 29 22:19:11 2015 +0800
+++ b/cli-runopts.c	Wed Oct 21 22:05:50 2015 +0800
@@ -218,8 +218,12 @@
 
 		if (argv[i][0] == '-') {
 			/* A flag *waves* */
-
-			switch (argv[i][1]) {
+			char c = argv[i][1];
+			if (strlen(argv[i]) != 2) {
+				/* Ensure only one flag per hyphen. '?' falls through to print help */
+				c = '?';
+			}
+			switch (c) {
 				case 'y': /* always accept the remote hostkey */
 					if (cli_opts.always_accept_key) {
 						/* twice means no checking at all */
--- a/dbclient.1	Tue Sep 29 22:19:11 2015 +0800
+++ b/dbclient.1	Wed Oct 21 22:05:50 2015 +0800
@@ -3,7 +3,7 @@
 dbclient \- lightweight SSH client
 .SH SYNOPSIS
 .B dbclient
-[\-Tt] [\-p
+[flag arguments] [\-p
 .I port\fR] [\-i
 .I id\fR] [\-L
 .I l\fR:\fIh\fR:\fIr\fR] [\-R
--- a/dropbear.8	Tue Sep 29 22:19:11 2015 +0800
+++ b/dropbear.8	Wed Oct 21 22:05:50 2015 +0800
@@ -3,7 +3,7 @@
 dropbear \- lightweight SSH server
 .SH SYNOPSIS
 .B dropbear
-[\-RFEmwsgjki] [\-b
+[flag arguments] [\-b
 .I banner\fR] 
 [\-r
 .I hostkeyfile\fR] [\-p
--- a/svr-runopts.c	Tue Sep 29 22:19:11 2015 +0800
+++ b/svr-runopts.c	Wed Oct 21 22:05:50 2015 +0800
@@ -189,7 +189,12 @@
 		}
 
 		if (argv[i][0] == '-') {
-			switch (argv[i][1]) {
+			char c = argv[i][1];
+			if (strlen(argv[i]) != 2) {
+				/* Ensure only one flag per hyphen. '?' falls through to print help */
+				c = '?';
+			}
+			switch (c) {
 				case 'b':
 					next = &svr_opts.bannerfile;
 					break;