summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/lib/compat.c
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1996-12-17 00:55:20 +0000
committerpst <pst@FreeBSD.org>1996-12-17 00:55:20 +0000
commit253df5b08a3b317eaf4a167361219cc2de05aa31 (patch)
tree19c4dd1a0d2247fce3e58d233ea6294b83fd819d /usr.sbin/cron/lib/compat.c
parentf5dbed887331c9ef9a08faa00caa1cb9cfa9d579 (diff)
downloadFreeBSD-src-253df5b08a3b317eaf4a167361219cc2de05aa31.zip
FreeBSD-src-253df5b08a3b317eaf4a167361219cc2de05aa31.tar.gz
Replace my "inane" usage of snprintf to copy strings with strncpy as
used by OpenBSD. (Quite frankly, I think it's perfectly reasonable to use snprintf to copy strings, given that the semantics for strncpy() are utterly idiotic and there is no POSIX sstrncpy().) While I'm at it, incorporate some of OpenBSD's bugfixes to cron. NOT for 2.2
Diffstat (limited to 'usr.sbin/cron/lib/compat.c')
-rw-r--r--usr.sbin/cron/lib/compat.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/cron/lib/compat.c b/usr.sbin/cron/lib/compat.c
index 87eeacc..eb69fcd 100644
--- a/usr.sbin/cron/lib/compat.c
+++ b/usr.sbin/cron/lib/compat.c
@@ -16,7 +16,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: compat.c,v 1.1.1.1 1994/08/27 13:43:02 jkh Exp $";
+static char rcsid[] = "$Id: compat.c,v 1.2 1996/11/01 23:27:28 millert Exp $";
#endif
/* vix 30dec93 [broke this out of misc.c - see RCS log for history]
@@ -53,7 +53,10 @@ strdup(str)
{
char *temp;
- temp = malloc(strlen(str) + 1);
+ if ((temp = malloc(strlen(str) + 1)) == NULL) {
+ errno = ENOMEM;
+ return NULL;
+ }
(void) strcpy(temp, str);
return temp;
}
@@ -143,7 +146,7 @@ getdtablesize() {
* Snarfage done by Jarkko Hietaniemi <Jarkko.Hietaniemi@hut.fi>
* *) well, almost, had to K&R the function entry, HPUX "cc"
* does not grok ANSI function prototypes */
-
+
/*
* flock (fd, operation)
*
@@ -199,13 +202,13 @@ flock(fd, operation)
case LOCK_UN: /* unlock */
i = lockf (fd, F_ULOCK, 0);
break;
-
+
default: /* can't decipher operation */
i = -1;
errno = EINVAL;
break;
}
-
+
return (i);
}
#endif /*NEED_FLOCK*/
@@ -227,7 +230,7 @@ setenv(name, value, overwrite)
return -1;
}
- sprintf("%s=%s", name, value);
+ sprintf(tmp, "%s=%s", name, value);
return putenv(tmp); /* intentionally orphan 'tmp' storage */
}
#endif
OpenPOWER on IntegriCloud