Skip to content

Commit

Permalink
Long opt
Browse files Browse the repository at this point in the history
- `opt`: Fix #234: correctly calculate option length and check if argument contains anything
  • Loading branch information
jelu committed Mar 14, 2023
1 parent a28d2b8 commit e6dbd78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ static int perf_opt_long_parse(char* optarg)
char* arg;

if ((arg = strchr(optarg, '='))) {
optlen = arg - optarg;
arg++;
optlen = strlen(arg);
if (optlen < 1) {
if (optlen < 1 || !strlen(arg)) {
return -1;
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/test/test1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

# test for broken long opt in v2.11.0
../dnsperf -O suppress=test 2>&1 |grep -q "unknown message type to suppress: test"
# ...and in v2.11.1, issue #234
../dnsperf -O doh-uri=https://blahblah.com/dns-query -O suppress=timeouts -h

0 comments on commit e6dbd78

Please sign in to comment.