Skip to content

Should error on invalid integers in CLI arguments #273

Description

@decorator-factory

Both of these commands:

$ nsjail -Mo --time_limit 0.7 --chroot / -- /bin/bash
$ nsjail -Mo --time_limit 🍌🍌🍌 --chroot / -- /bin/bash

will limit the execution time to 600 seconds (the default), or whatever is provided in the config if a config file is supplied.

And this will set the limit to 1 second, not 1.5 seconds:

$ nsjail -Mo --time_limit 1.5 --chroot / -- /bin/bash

It's understandable to only support integer durations, but I think invalid values should result in an error, not silently using the default.


This is the problematic code:

nsjail/cmdline.cc

Lines 568 to 570 in d6454b4

case 't':
nsj->njc.set_time_limit((uint64_t)strtoull(optarg, NULL, 0));
break;

It seems like it's calling strtoull without checking whether the entire argument constitutes an integer. strto... is called like that in several places

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions