Commit 8eb8899
libbpf-tools/memleak: Fix to handle failure for invalid arguments (iovisor#5147)
Argument parsing errors are not detected for -p, -o, and -T due to the use of
atoi.
So, fixed these to handle invalid arguments by using strtol instead.
Before:
# ./memleak_new -p haha
using default object: libc.so.6
using page size: 4096
tracing kernel: false
Tracing outstanding memory allocs... Hit Ctrl-C to end
# ./memleak -o 99999999999999999999999999999999999999999999999
using default object: libc.so.6
using page size: 4096
tracing kernel: true
Tracing outstanding memory allocs... Hit Ctrl-C to end
After:
# ./memleak_new -p haha
error arg:p haha
Usage: memleak_new [OPTION...]
Try `memleak_new --help' or `memleak_new --usage' for more information.
# ./memleak_new -o 99999999999999999999999999999999999999999999999
error arg:o 99999999999999999999999999999999999999999999999
Usage: memleak_new [OPTION...]
Try `memleak_new --help' or `memleak_new --usage' for more information.
# ./memleak_new -o 9999999999999999
invalid AGE_MS: 9999999999999999
Usage: memleak_new [OPTION...]
Try `memleak_new --help' or `memleak_new --usage' for more information.1 parent b048533 commit 8eb8899
1 file changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
514 | | - | |
| 515 | + | |
515 | 516 | | |
516 | 517 | | |
517 | 518 | | |
| |||
520 | 521 | | |
521 | 522 | | |
522 | 523 | | |
523 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
524 | 530 | | |
525 | 531 | | |
526 | 532 | | |
| |||
538 | 544 | | |
539 | 545 | | |
540 | 546 | | |
541 | | - | |
| 547 | + | |
542 | 548 | | |
543 | 549 | | |
544 | 550 | | |
| |||
0 commit comments