aboutsummaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-05-03 18:40:20 +0200
committerPetr Machata <pmachata@redhat.com>2012-05-03 18:40:20 +0200
commit5bddfccaa50aa9de2f58cbe8fa754ded3c7ad2eb (patch)
tree1e791b7ce6ccb4c0ed49bca278bc023ea2893cef /options.c
parent61686c26634ea847c41470801572b49bebce5b99 (diff)
downloadltrace-5bddfccaa50aa9de2f58cbe8fa754ded3c7ad2eb.tar.gz
Better checking for -n argument
Diffstat (limited to 'options.c')
-rw-r--r--options.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/options.c b/options.c
index d5edc1a..8dce7f8 100644
--- a/options.c
+++ b/options.c
@@ -494,9 +494,19 @@ process_options(int argc, char **argv)
case 'L':
libcalls = 0;
break;
- case 'n':
- options.indent = atoi(optarg);
+ case 'n': {
+ char *endptr;
+ long int l = strtol(optarg, &endptr, 0);
+ /* Arbitrary cut-off. Nobody needs to indent
+ * more than, say, 8, anyway. */
+ if (l < 0 || l > 20 || *optarg == 0 || *endptr != 0) {
+ fprintf(stderr, "Invalid argument to -n: '%s'."
+ " Use integer 0..20.\n", optarg);
+ exit(1);
+ }
+ options.indent = (int)l;
break;
+ }
case 'o':
options.output = fopen(optarg, "w");
if (!options.output) {