File vixie-cron-4.1-segfault.patch of Package cron
Index: do_command.c
===================================================================
--- do_command.c.orig
+++ do_command.c
@@ -512,24 +512,13 @@ child_process(entry *e, user *u) {
/* this was the first char from the pipe
*/
putc(ch, mail);
- }
- /* we have to read the input pipe no matter whether
- * we mail or not, but obviously we only write to
- * mail pipe if we ARE mailing.
- */
-
- while (EOF != (ch = getc(in))) {
- bytes++;
- if (mailto)
+ while (EOF != (ch = getc(in))) {
+ bytes++;
putc(ch, mail);
- }
- /* only close pipe if we opened it -- i.e., we're
- * mailing...
- */
+ }
- if (mailto) {
Debug(DPROC, ("[%ld] closing pipe to mail\n",
(long)getpid()))
/* Note: the pclose will probably see
@@ -539,20 +528,28 @@ child_process(entry *e, user *u) {
* after closing its stdout.
*/
status = cron_pclose(mail);
- }
- /* if there was output and we could not mail it,
- * log the facts so the poor user can figure out
- * what's going on.
- */
- if (mailto && status) {
- char buf[MAX_TEMPSTR];
-
- sprintf(buf,
- "mailed %d byte%s of output but got status 0x%04x\n",
- bytes, (bytes==1)?"":"s",
- status);
- log_it(usernm, getpid(), "MAIL", buf);
+ /* if there was output and we could not mail it,
+ * log the facts so the poor user can figure out
+ * what's going on.
+ */
+ if (status) {
+ char buf[MAX_TEMPSTR];
+
+ sprintf(buf,
+ "mailed %d byte%s of output but"
+ "got status 0x%04x\n",
+ bytes, (bytes==1)?"":"s",
+ status);
+ log_it(usernm, getpid(), "MAIL", buf);
+ }
+ } else {
+ /* we have to read the input pipe no matter whether
+ * we mail or not, but obviously we only write to
+ * mail pipe if we ARE mailing.
+ */
+ while (EOF != (ch = getc(in)))
+ bytes++;
}
} /*if data from grandchild*/
@@ -595,7 +592,7 @@ child_process(entry *e, user *u) {
static int
safe_p(const char *usernm, const char *s) {
- static const char safe_delim[] = "@!:%-.,"; /* conservative! */
+ static const char safe_delim[] = "@!:%-.,+"; /* conservative! */
const char *t;
int ch, first;