summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-07-11 20:15:40 +0000
committermillert <millert@openbsd.org>2002-07-11 20:15:40 +0000
commitd54c3a7cc52402eb0ba58956eeb4c3531c016cac (patch)
treea4c4fdca31911be17629c78fc2df73448b2dc8b3
parentdo not let the group access the sem (diff)
downloadwireguard-openbsd-d54c3a7cc52402eb0ba58956eeb4c3531c016cac.tar.xz
wireguard-openbsd-d54c3a7cc52402eb0ba58956eeb4c3531c016cac.zip
More syncing with my cron 4.0 patch tree, basically cosmetic:
o change an instance of e_none to e_memory that I missed (forgot?) o kill some whitespace o modify malloc failure recovery a bit
-rw-r--r--usr.sbin/cron/entry.c6
-rw-r--r--usr.sbin/cron/env.c32
-rw-r--r--usr.sbin/cron/job.c8
-rw-r--r--usr.sbin/cron/user.c9
4 files changed, 27 insertions, 28 deletions
diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c
index f091ef28853..b672babcc9d 100644
--- a/usr.sbin/cron/entry.c
+++ b/usr.sbin/cron/entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entry.c,v 1.11 2002/07/11 19:29:36 millert Exp $ */
+/* $OpenBSD: entry.c,v 1.12 2002/07/11 20:15:40 millert Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char const rcsid[] = "$OpenBSD: entry.c,v 1.11 2002/07/11 19:29:36 millert Exp $";
+static char const rcsid[] = "$OpenBSD: entry.c,v 1.12 2002/07/11 20:15:40 millert Exp $";
#endif
/* vix 26jan87 [RCS'd; rest of log is in RCS file]
@@ -359,7 +359,7 @@ load_entry(FILE *file, void (*error_func)(), struct passwd *pw, char **envp) {
/* got the command in the 'cmd' string; save it in *e.
*/
if ((e->cmd = strdup(cmd)) == NULL) {
- ecode = e_none;
+ ecode = e_memory;
goto eof;
}
diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c
index 945956d4e0d..51070680e14 100644
--- a/usr.sbin/cron/env.c
+++ b/usr.sbin/cron/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.12 2002/07/09 18:59:12 millert Exp $ */
+/* $OpenBSD: env.c,v 1.13 2002/07/11 20:15:40 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*/
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char const rcsid[] = "$OpenBSD: env.c,v 1.12 2002/07/09 18:59:12 millert Exp $";
+static char const rcsid[] = "$OpenBSD: env.c,v 1.13 2002/07/11 20:15:40 millert Exp $";
#endif
#include "cron.h"
@@ -39,7 +39,7 @@ void
env_free(char **envp) {
char **p;
- for (p = envp; *p != NULL; p++)
+ for (p = envp; *p != NULL; p++)
free(*p);
free(envp);
}
@@ -49,11 +49,11 @@ env_copy(char **envp) {
int count, i, save_errno;
char **p;
- for (count = 0; envp[count] != NULL; count++)
+ for (count = 0; envp[count] != NULL; count++)
continue;
p = (char **) malloc((count+1) * sizeof(char *)); /* 1 for the NULL */
if (p != NULL) {
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
if ((p[i] = strdup(envp[i])) == NULL) {
save_errno = errno;
while (--i >= 0)
@@ -70,14 +70,14 @@ env_copy(char **envp) {
char **
env_set(char **envp, char *envstr) {
int count, found;
- char **p, *cp;
+ char **p, *envtmp;
/*
* count the number of elements, including the null pointer;
* also set 'found' to -1 or index of entry if already in here.
*/
found = -1;
- for (count = 0; envp[count] != NULL; count++) {
+ for (count = 0; envp[count] != NULL; count++) {
if (!strcmp_until(envp[count], envstr, '='))
found = count;
}
@@ -88,11 +88,10 @@ env_set(char **envp, char *envstr) {
* it exists already, so just free the existing setting,
* save our new one there, and return the existing array.
*/
- free(envp[found]);
- if ((envp[found] = strdup(envstr)) == NULL) {
- envp[found] = "";
+ if ((envtmp = strdup(envstr)) == NULL)
return (NULL);
- }
+ free(envp[found]);
+ envp[found] = envtmp;
return (envp);
}
@@ -101,15 +100,16 @@ env_set(char **envp, char *envstr) {
* one, save our string over the old null pointer, and return resized
* array.
*/
+ if ((envtmp = strdup(envstr)) == NULL)
+ return (NULL);
p = (char **) realloc((void *) envp,
(size_t) ((count+1) * sizeof(char **)));
- if (p == NULL)
+ if (p == NULL) {
+ free(envtmp);
return (NULL);
- cp = strdup(envstr);
- if (cp == NULL)
- return(NULL);
+ }
p[count] = p[count-1];
- p[count-1] = cp;
+ p[count-1] = envtmp;
return (p);
}
diff --git a/usr.sbin/cron/job.c b/usr.sbin/cron/job.c
index 876fa2c0c83..9e8a15fdb50 100644
--- a/usr.sbin/cron/job.c
+++ b/usr.sbin/cron/job.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: job.c,v 1.4 2002/07/08 18:11:02 millert Exp $ */
+/* $OpenBSD: job.c,v 1.5 2002/07/11 20:15:40 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*/
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char const rcsid[] = "$OpenBSD: job.c,v 1.4 2002/07/08 18:11:02 millert Exp $";
+static char const rcsid[] = "$OpenBSD: job.c,v 1.5 2002/07/11 20:15:40 millert Exp $";
#endif
#include "cron.h"
@@ -44,9 +44,9 @@ job_add(entry *e, user *u) {
return;
/* build a job queue element */
- if ((j = (job*)malloc(sizeof(job))) == NULL)
+ if ((j = (job *)malloc(sizeof(job))) == NULL)
return;
- j->next = (job*) NULL;
+ j->next = NULL;
j->e = e;
j->u = u;
diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c
index 12f7e375cd0..de60ed83eb6 100644
--- a/usr.sbin/cron/user.c
+++ b/usr.sbin/cron/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.4 2002/07/08 18:11:02 millert Exp $ */
+/* $OpenBSD: user.c,v 1.5 2002/07/11 20:15:40 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*/
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static const char rcsid[] = "$OpenBSD: user.c,v 1.4 2002/07/08 18:11:02 millert Exp $";
+static const char rcsid[] = "$OpenBSD: user.c,v 1.5 2002/07/11 20:15:40 millert Exp $";
#endif
/* vix 26jan87 [log is in RCS file]
@@ -95,15 +95,14 @@ load_user(int crontab_fd, struct passwd *pw, const char *name) {
}
break;
case TRUE:
- if ((tenvp = env_set(envp, envstr))) {
- envp = tenvp;
- } else {
+ if ((tenvp = env_set(envp, envstr)) == NULL) {
save_errno = errno;
free_user(u);
u = NULL;
errno = save_errno;
goto done;
}
+ envp = tenvp;
break;
}
}