static gid_t run_gid;
unsigned int max_strlen = DEFAULT_STRLEN;
-static unsigned int acolumn = DEFAULT_ACOLUMN;
+static int acolumn = DEFAULT_ACOLUMN;
static char *acolumn_spaces;
static char *outfname = NULL;
error_msg_and_die("Out of memory");
}
+static void
+error_opt_arg(int opt, const char *arg)
+{
+ error_msg_and_die("Invalid -%c argument: '%s'", opt, arg);
+}
+
/* Glue for systems without a MMU that cannot provide fork() */
#ifdef HAVE_FORK
# define strace_vforked 0
char c = *delim;
*delim = '\0';
- pid = atoi(opt); /* TODO: stricter parsing of the number? */
+ pid = string_to_uint(opt);
if (pid <= 0) {
- error_msg("Invalid process id: '%s'", opt);
+ error_msg_and_die("Invalid process id: '%s'", opt);
*delim = c;
return;
}
if (pid == strace_tracer_pid) {
- error_msg("I'm sorry, I can't let you do that, Dave.");
+ error_msg_and_die("I'm sorry, I can't let you do that, Dave.");
*delim = c;
return;
}
if (de->d_fileno == 0)
continue;
+ /* we trust /proc filesystem */
tid = atoi(de->d_name);
if (tid <= 0)
continue;
init(int argc, char *argv[])
{
struct tcb *tcp;
- int c;
+ int c, i;
int optF = 0;
struct sigaction sa;
not_failing_only = 1;
break;
case 'a':
- acolumn = atoi(optarg);
+ acolumn = string_to_uint(optarg);
if (acolumn < 0)
- error_msg_and_die("Bad column width '%s'", optarg);
+ error_opt_arg(c, optarg);
break;
case 'e':
qualify(optarg);
outfname = strdup(optarg);
break;
case 'O':
- set_overhead(atoi(optarg));
+ i = string_to_uint(optarg);
+ if (i < 0)
+ error_opt_arg(c, optarg);
+ set_overhead(i);
break;
case 'p':
process_opt_p_list(optarg);
}
break;
case 's':
- max_strlen = atoi(optarg);
- if (max_strlen < 0) {
- error_msg_and_die("Invalid -%c argument: '%s'", c, optarg);
- }
+ i = string_to_uint(optarg);
+ if (i < 0)
+ error_opt_arg(c, optarg);
+ max_strlen = i;
break;
case 'S':
set_sortby(optarg);
die_out_of_memory();
break;
case 'I':
- opt_intr = atoi(optarg);
- if (opt_intr <= 0 || opt_intr >= NUM_INTR_OPTS) {
- error_msg_and_die("Invalid -%c argument: '%s'", c, optarg);
- }
+ opt_intr = string_to_uint(optarg);
+ if (opt_intr <= 0 || opt_intr >= NUM_INTR_OPTS)
+ error_opt_arg(c, optarg);
break;
default:
usage(stderr, 1);
int rc = -1;
if (*s >= '0' && *s <= '9') {
- int i = atoi(s);
+ int i = string_to_uint(s);
if (i < 0 || i >= MAX_QUALS)
return -1;
qualify_one(i, bitflag, not, -1);
int i;
if (*s >= '0' && *s <= '9') {
- int signo = atoi(s);
+ int signo = string_to_uint(s);
if (signo < 0 || signo >= MAX_QUALS)
return -1;
qualify_one(signo, bitflag, not, -1);
qual_desc(const char *s, int bitflag, int not)
{
if (*s >= '0' && *s <= '9') {
- int desc = atoi(s);
+ int desc = string_to_uint(s);
if (desc < 0 || desc >= MAX_QUALS)
return -1;
qualify_one(desc, bitflag, not, -1);