diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-09-02 15:19:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-09-02 15:19:41 +0000 |
commit | 6ebd04219f0d749c87a763e8afb578dfcd5223cc (patch) | |
tree | bb0f29e0a3791fff88551c93f5d4ba7113bdba43 /usr.bin/at/at.c | |
parent | be524287dc216d876f995eddcaf32762c702c6e9 (diff) |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/at/at.c')
-rw-r--r-- | usr.bin/at/at.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index b256401a81e..2b96877bcd7 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -1,4 +1,4 @@ -/* $OpenBSD: at.c,v 1.52 2007/06/18 11:20:58 millert Exp $ */ +/* $OpenBSD: at.c,v 1.53 2007/09/02 15:19:31 deraadt Exp $ */ /* * at.c : Put file into atrun queue @@ -42,7 +42,7 @@ #define TIMESIZE 50 /* Size of buffer passed to strftime() */ #ifndef lint -static const char rcsid[] = "$OpenBSD: at.c,v 1.52 2007/06/18 11:20:58 millert Exp $"; +static const char rcsid[] = "$OpenBSD: at.c,v 1.53 2007/09/02 15:19:31 deraadt Exp $"; #endif /* Variables to remove from the job's environment. */ @@ -489,7 +489,7 @@ list_jobs(int argc, char **argv, int count_only, int csort) int i, shortformat, numjobs, maxjobs; if (argc) { - if ((uids = malloc(sizeof(uid_t) * argc)) == NULL) + if ((uids = calloc(sizeof(uid_t), argc)) == NULL) panic("Insufficient virtual memory"); for (i = 0; i < argc; i++) { @@ -524,7 +524,7 @@ list_jobs(int argc, char **argv, int count_only, int csort) */ numjobs = 0; maxjobs = stbuf.st_nlink + 4; - atjobs = (struct atjob **)malloc(maxjobs * sizeof(struct atjob *)); + atjobs = (struct atjob **)calloc(maxjobs, sizeof(struct atjob *)); if (atjobs == NULL) panic("Insufficient virtual memory"); @@ -663,8 +663,8 @@ process_jobs(int argc, char **argv, int what) uids = NULL; jobs_len = uids_len = 0; if (argc > 0) { - if ((jobs = malloc(sizeof(char *) * argc)) == NULL || - (uids = malloc(sizeof(uid_t) * argc)) == NULL) + if ((jobs = calloc(sizeof(char *), argc)) == NULL || + (uids = calloc(sizeof(uid_t), argc)) == NULL) panic("Insufficient virtual memory"); for (i = 0; i < argc; i++) { |