diff --git a/skill.c b/skill.c index 0f421d3b..3a92f091 100644 --- a/skill.c +++ b/skill.c @@ -65,7 +65,9 @@ static struct procps_namespaces match_namespaces; static int ns_flags = 0x3f; #define ENLIST(thing,addme) do{ \ -if(!thing##s) thing##s = xmalloc(sizeof(*thing##s)*saved_argc); \ +if(thing##_count < 0 || (size_t)thing##_count >= INT_MAX / sizeof(*thing##s)) \ + xerrx(EXIT_FAILURE, _("integer overflow")); \ +thing##s = xrealloc(thing##s, sizeof(*thing##s)*(thing##_count+1)); \ thing##s[thing##_count++] = addme; \ }while(0) @@ -82,7 +84,6 @@ enum rel_items { EU_PID, EU_EUID, EU_EUSER, EU_TTY, EU_TTYNAME, EU_CMD}; static int my_pid; -static int saved_argc; static int sig_or_pri;