summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cron
diff options
context:
space:
mode:
authorbasabi <none@none>2007-12-03 14:32:45 -0800
committerbasabi <none@none>2007-12-03 14:32:45 -0800
commitd9f271072c38ba07dd14b0e73464e3b6adca60fa (patch)
tree878c20408eb165be28420da607aff702a37a0216 /usr/src/cmd/cron
parent635ad929b1c9dfc0b3e4defaa2738fdbf4fa9725 (diff)
downloadillumos-gate-d9f271072c38ba07dd14b0e73464e3b6adca60fa.tar.gz
6636777 *cron* coredumps on NULL home directory
Diffstat (limited to 'usr/src/cmd/cron')
-rw-r--r--usr/src/cmd/cron/cron.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr/src/cmd/cron/cron.c b/usr/src/cmd/cron/cron.c
index 189d0d4727..75e7106d5e 100644
--- a/usr/src/cmd/cron/cron.c
+++ b/usr/src/cmd/cron/cron.c
@@ -898,8 +898,13 @@ mod_ctab(char *name, time_t reftime)
} else {
u->uid = pw->pw_uid;
u->gid = pw->pw_gid;
- if (strcmp(u->home, pw->pw_dir) != 0) {
- free(u->home);
+ if (u->home != NULL) {
+ if (strcmp(u->home, pw->pw_dir) != 0) {
+ free(u->home);
+ u->home = xmalloc(strlen(pw->pw_dir) + 1);
+ (void) strcpy(u->home, pw->pw_dir);
+ }
+ } else {
u->home = xmalloc(strlen(pw->pw_dir) + 1);
(void) strcpy(u->home, pw->pw_dir);
}