comparison cli-runopts.c @ 1220:de2e39e94c68

revert removal of space handling, different fix for avoiding option prefix matches
author Matt Johnston <matt@ucc.asn.au>
date Tue, 15 Dec 2015 22:57:22 +0800
parents b73c078e11e9
children 888e3d17e962
comparison
equal deleted inserted replaced
1218:b73c078e11e9 1220:de2e39e94c68
822 dropbear_exit("Bad TCP port in '%s'", origstr); 822 dropbear_exit("Bad TCP port in '%s'", origstr);
823 } 823 }
824 #endif 824 #endif
825 825
826 static int match_extendedopt(const char** strptr, const char *optname) { 826 static int match_extendedopt(const char** strptr, const char *optname) {
827 int seen_eq = 0;
827 int optlen = strlen(optname); 828 int optlen = strlen(optname);
828 const char *str = *strptr; 829 const char *str = *strptr;
829 830
831 while (isspace(*str)) {
832 ++str;
833 }
834
830 if (strncasecmp(str, optname, optlen) != 0) { 835 if (strncasecmp(str, optname, optlen) != 0) {
831 return DROPBEAR_FAILURE; 836 return DROPBEAR_FAILURE;
832 } 837 }
833 838
834 str += optlen; 839 str += optlen;
835 840
836 if (*str == '=') { 841 while (isspace(*str) || (!seen_eq && *str == '=')) {
837 *strptr = str+1; 842 if (*str == '=') {
838 return DROPBEAR_SUCCESS; 843 seen_eq = 1;
839 } else { 844 }
845 ++str;
846 }
847
848 if (str-*strptr == optlen) {
849 /* matched just a prefix of optname */
840 return DROPBEAR_FAILURE; 850 return DROPBEAR_FAILURE;
841 } 851 }
842 852
853 *strptr = str;
854 return DROPBEAR_SUCCESS;
843 } 855 }
844 856
845 static int parse_flag_value(const char *value) { 857 static int parse_flag_value(const char *value) {
846 if (strcmp(value, "yes") == 0 || strcmp(value, "true") == 0) { 858 if (strcmp(value, "yes") == 0 || strcmp(value, "true") == 0) {
847 return 1; 859 return 1;