mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-10-29 11:45:17 +08:00
Reject empty fsession CLI values
This commit is contained in:
@@ -63,7 +63,7 @@ static int parse_u64(const char *value, unsigned long long maximum,
|
||||
|
||||
errno = 0;
|
||||
parsed = strtoull(value, &end, 10);
|
||||
if (errno || !end || *end || parsed > maximum)
|
||||
if (errno || end == value || *end || parsed > maximum)
|
||||
return -EINVAL;
|
||||
*result = parsed;
|
||||
return 0;
|
||||
|
||||
@@ -101,6 +101,16 @@ def main() -> int:
|
||||
assert invalid.returncode != 0
|
||||
assert "invalid duration" in invalid.stdout
|
||||
|
||||
empty_threshold = subprocess.run(
|
||||
[binary, "--threshold-us", ""],
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
check=False,
|
||||
)
|
||||
assert empty_threshold.returncode != 0
|
||||
assert "invalid threshold" in empty_threshold.stdout
|
||||
|
||||
pid = str(os.getpid())
|
||||
missed, _ = run_trace(
|
||||
binary,
|
||||
|
||||
Reference in New Issue
Block a user