Skip to content

Commit 156ceda

Browse files
authored
Update run.cpp
enforce that and argument must have at least length 2, and refine check for uniarg (ie arg plus flag value in one option) to be args with more than 2 characters
1 parent c787e1a commit 156ceda

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

runner/run.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,12 @@ int main(int argc, char *argv[]) {
811811
error_usage();
812812
} // must start with dash
813813

814+
if strlen(argv[i]) < 2 {
815+
error_usage();
816+
} // must have at least dash '-' and option letter
817+
814818
// uniarg means the arg comes right after the letter in accordance with posix
815-
int uniarg = strlen(argv[i]) != 2;
819+
int uniarg = strlen(argv[i]) > 2;
816820
if (uniarg) {
817821
parm=&argv[i][2];
818822
} else if (i + 1 >= argc) {

0 commit comments

Comments
 (0)