Skip to content

Commit

Permalink
Better error message for jail_prober.py cli usage
Browse files Browse the repository at this point in the history
Curerently sys.argv is accessed without checks, resulting in an
IndexError:
```
Traceback (most recent call last):
  File "/home/rusty-snake/Projects/firejail/contrib/jail_prober.py", line 205, in <module>
    main()
  File "/home/rusty-snake/Projects/firejail/contrib/jail_prober.py", line 170, in main
    profile_path = sys.argv[1]
IndexError: list index out of range
```

This commit catches this IndexError and prints a more helpfull message
instaed:
```
USAGE: jail_prober.py <PROFILE-PATH> <PROGRAM>
```
  • Loading branch information
rusty-snake committed Jun 4, 2021
1 parent d371aae commit 0dc82f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contrib/jail_prober.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ def run_firejail(program, all_args):


def main():
profile_path = sys.argv[1]
program = sys.argv[2]
try:
profile_path = sys.argv[1]
program = sys.argv[2]
except IndexError:
print('USAGE: jail_prober.py <PROFILE-PATH> <PROGRAM>')
sys.exit()
# Quick error check and extract arguments
check_params(profile_path)
profile = get_args(profile_path)
Expand Down

0 comments on commit 0dc82f0

Please sign in to comment.