0086-pmap: Prevent integer overflow in main().
Unlikely to ever happen, but just in case. Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
105ab093b8
commit
bf409f92fd
3
pmap.c
3
pmap.c
@ -30,6 +30,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
@ -1136,6 +1137,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((size_t)argc >= INT_MAX / sizeof(pid_t))
|
||||||
|
xerrx(EXIT_FAILURE, _("too many arguments"));
|
||||||
if (procps_pids_new(&Pids_info, Pid_items, 4))
|
if (procps_pids_new(&Pids_info, Pid_items, 4))
|
||||||
xerrx(EXIT_FAILURE, _("library failed pids statistics"));
|
xerrx(EXIT_FAILURE, _("library failed pids statistics"));
|
||||||
pidlist = xmalloc(sizeof(pid_t) * argc);
|
pidlist = xmalloc(sizeof(pid_t) * argc);
|
||||||
|
Loading…
Reference in New Issue
Block a user