cronie-crond / cronie

Cronie cron daemon project
Other
481 stars 81 forks source link

Anacron Email noification cannot be send #185

Closed jenslauterbach11 closed 4 months ago

jenslauterbach11 commented 4 months ago

Release 1.7.2 (fedora) an AARCH64 (Raspberry PI 4)

I have configured in anacrontab with MAILTO=root Nevertheless the email with console output is not send. It is failing with: Syntax error in mailbox address "p+?t??" (non-printable character) ... Tried to mail output of job `cron.weekly', but mailer process (/usr/sbin/sendmail) exited with status 64

The reason seems to be that in runjob.c:launch_job a pointer to a local reference is stored in jr->mailto. According to documentation the output of getenv might get invalidated when getenv is called again (see posix standard) I have the feeling that the address might also get invalidated after fork (before fork the mailto address seems still to be valid) I think strdup should be used to store the result of getenv. A local workaround by adding strdup in line 365 jr->mailto = strdup(mailto); seems to solve the problem for me. Unfortunately this will lead to a memory leak as _jr->mailto is never released.

t8m commented 4 months ago

Fix was merged. Using strdup is fine as the leak is on exit only anyway. The job array is not released either.