Skip to content

Reject invalid integer command-line arguments#281

Open
attaboy11 wants to merge 1 commit into
google:masterfrom
attaboy11:fix/strict-cli-integers-273
Open

Reject invalid integer command-line arguments#281
attaboy11 wants to merge 1 commit into
google:masterfrom
attaboy11:fix/strict-cli-integers-273

Conversation

@attaboy11

Copy link
Copy Markdown

Summary

  • require complete, in-range integer parsing for numeric command-line options
  • reject negative unsigned values and conversions that overflow their destination types
  • preserve valid decimal, octal, hexadecimal, signed-option, and special rlimit syntax
  • add a focused test-cmdline target for malformed and valid values

Motivation

The existing strto* calls did not check whether the entire argument was consumed and, in several cases, narrowed values without a range check. Inputs such as --time_limit 1.5 could therefore be silently truncated or leave configured defaults in effect. For resource and cgroup limits, that can make a sandbox less restrictive than the operator intended.

The strict helpers are also used for UID/GID input and mapping counts so malformed numeric-looking identities cannot pass through partial conversion.

Fixes #273.

Testing

  • docker build --target build -t nsjail-strict-cli .
  • docker run --rm nsjail-strict-cli make -C /nsjail test-cmdline
  • privileged standalone smoke test with /bin/true
  • clang-format --dry-run --Werror on all changed regions

@google-cla

google-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@attaboy11
attaboy11 marked this pull request as ready for review July 16, 2026 19:50
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.

Should error on invalid integers in CLI arguments

1 participant