Skip to content

Validate CLI seed and server port arguments#234

Open
FabioMalpezzi wants to merge 1 commit into
antirez:mainfrom
FabioMalpezzi:fix-cli-arg-validation
Open

Validate CLI seed and server port arguments#234
FabioMalpezzi wants to merge 1 commit into
antirez:mainfrom
FabioMalpezzi:fix-cli-arg-validation

Conversation

@FabioMalpezzi
Copy link
Copy Markdown

Summary

Reject a couple of invalid argument values before they can reach runtime setup:

  • reject negative --seed values in ds4, ds4-agent, and ds4-eval
  • reject ds4-server --port values outside the valid TCP port range 1..65535

strtoull() accepts strings like -1, which previously let negative seed input wrap into a large uint64_t. The server also accepted ports above 65535, which were later narrowed through the uint16_t cast used for htons().

Testing

make ds4 ds4-agent ds4-eval ds4-server
./ds4 --seed -1 --help
./ds4 --seed 0 --help
./ds4 --seed 18446744073709551616 --help
./ds4 --seed +1 --help
./ds4-agent --seed -1 --help
./ds4-eval --seed -1 --help
./ds4-server --port 70000 --help
./ds4-server --port +65535 --help
git diff --check
./ds4-eval --self-test-extractors
./ds4_test --server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant