Commit 8ee00785 authored by Timo Teräs's avatar Timo Teräs
Browse files

main/busybox: fix disappearing crontabs bug

It's uninitialized memory use bug. The relevant parts are rewritten
in busybox-1.18.x and later, so this patch applies only to the
busybox-1.17.x versions. Fixes #436.
parent 1e43dab3
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.17.4
pkgrel=0
pkgrel=1
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="x86 x86_64"
......@@ -13,6 +13,7 @@ triggers="busybox.trigger:/bin /usr/bin /sbin /usr/sbin /lib/modules/*"
source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
ifupdown-ipv6.patch
$pkgname-1.11.1-bb.patch
$pkgname-1.17.4-crond.patch
busyboxconfig"
_builddir="$srcdir"/$pkgname-$pkgver
......@@ -72,4 +73,5 @@ static() {
md5sums="b3254232e9919007ca803d3a4fe81f3c busybox-1.17.4.tar.bz2
08af7b8b4e41f86a34a16270a8691e31 ifupdown-ipv6.patch
4c0f3b486eaa0674961b7ddcd0c60a9b busybox-1.11.1-bb.patch
fd451b1e8e6e976c99869dc2d149ccc9 busybox-1.17.4-crond.patch
403e0b9fe99a7a18c5b9ae91283a5f9a busyboxconfig"
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 4a3103c..7ba8bab 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -827,7 +827,7 @@ ForkJob(const char *user, CronLine *line, int mailFd,
static void RunJob(const char *user, CronLine *line)
{
- char mailFile[128];
+ char mailFile[128], *mail_filename = NULL;
int mailFd = -1;
line->cl_Pid = 0;
@@ -836,6 +836,7 @@ static void RunJob(const char *user, CronLine *line)
if (line->cl_MailTo) {
/* open mail file - owner root so nobody can screw with it. */
snprintf(mailFile, sizeof(mailFile), "%s/cron.%s.%d", TMPDIR, user, getpid());
+ mail_filename = mailFile;
mailFd = open(mailFile, O_CREAT | O_TRUNC | O_WRONLY | O_EXCL | O_APPEND, 0600);
if (mailFd >= 0) {
@@ -849,7 +850,7 @@ static void RunJob(const char *user, CronLine *line)
}
}
- ForkJob(user, line, mailFd, DEFAULT_SHELL, "-c", line->cl_Shell, mailFile);
+ ForkJob(user, line, mailFd, DEFAULT_SHELL, "-c", line->cl_Shell, mail_filename);
}
/*
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment