diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-11-09 01:12:28 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-11-09 01:12:28 +0000 |
commit | dde45024e22a1e683b4afb1d55bca6cda0e09030 (patch) | |
tree | 35ed5716966042a685e0dd59a92fc49df778abcd /usr.sbin/cron/user.c | |
parent | 5b5ef58c30e0cd58c8d01f280d0fe853d50b1f14 (diff) |
queue(3) instead of homegrown queues and lists. This also fixes
some potential memory leaks in error paths. OK guenther@
Diffstat (limited to 'usr.sbin/cron/user.c')
-rw-r--r-- | usr.sbin/cron/user.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c index d31d58056bc..2b896a32e3e 100644 --- a/usr.sbin/cron/user.c +++ b/usr.sbin/cron/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.16 2015/11/04 20:28:17 millert Exp $ */ +/* $OpenBSD: user.c,v 1.17 2015/11/09 01:12:27 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -34,13 +34,13 @@ void free_user(user *u) { - entry *e, *ne; + entry *e; - free(u->name); - for (e = u->crontab; e != NULL; e = ne) { - ne = e->next; + while ((e = SLIST_FIRST(&u->crontab))) { + SLIST_REMOVE_HEAD(&u->crontab, entries); free_entry(e); } + free(u->name); free(u); } @@ -69,7 +69,7 @@ load_user(int crontab_fd, struct passwd *pw, const char *name) errno = save_errno; return (NULL); } - u->crontab = NULL; + SLIST_INIT(&u->crontab); /* init environment. this will be copied/augmented for each entry. */ @@ -86,11 +86,10 @@ load_user(int crontab_fd, struct passwd *pw, const char *name) while ((status = load_env(envstr, file)) >= 0) { switch (status) { case FALSE: + /* Not an env variable, parse as crontab entry. */ e = load_entry(file, NULL, pw, envp); - if (e) { - e->next = u->crontab; - u->crontab = e; - } + if (e) + SLIST_INSERT_HEAD(&u->crontab, e, entries); break; case TRUE: if ((tenvp = env_set(envp, envstr)) == NULL) { |