|
|
96d6bf |
diff -ru cronie-1.5.2/anacron/readtab.c cronie-1.5.2_patched/anacron/readtab.c
|
|
|
96d6bf |
--- cronie-1.5.2/anacron/readtab.c 2017-09-14 13:53:21.000000000 +0200
|
|
|
96d6bf |
+++ cronie-1.5.2_patched/anacron/readtab.c 2018-09-07 15:13:17.752498050 +0200
|
|
|
96d6bf |
@@ -134,8 +134,19 @@
|
|
|
96d6bf |
|
|
|
96d6bf |
var_len = (int)strlen(env_var);
|
|
|
96d6bf |
val_len = (int)strlen(value);
|
|
|
96d6bf |
+ if (!var_len) {
|
|
|
96d6bf |
+ return;
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
er = obstack_alloc(&tab_o, sizeof(env_rec));
|
|
|
96d6bf |
+ if (er == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
|
|
|
96d6bf |
+ if (er->assign == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
strcpy(er->assign, env_var);
|
|
|
96d6bf |
er->assign[var_len] = '=';
|
|
|
96d6bf |
strcpy(er->assign + var_len + 1, value);
|
|
|
96d6bf |
@@ -167,15 +178,24 @@
|
|
|
96d6bf |
return;
|
|
|
96d6bf |
}
|
|
|
96d6bf |
jr = obstack_alloc(&tab_o, sizeof(job_rec));
|
|
|
96d6bf |
+ if (jr == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
jr->period = period;
|
|
|
96d6bf |
jr->named_period = 0;
|
|
|
96d6bf |
delay += random_number;
|
|
|
96d6bf |
jr->delay = delay;
|
|
|
96d6bf |
jr->tab_line = line_num;
|
|
|
96d6bf |
jr->ident = obstack_alloc(&tab_o, ident_len + 1);
|
|
|
96d6bf |
+ if (jr->ident == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
strcpy(jr->ident, ident);
|
|
|
96d6bf |
jr->arg_num = job_arg_num(ident);
|
|
|
96d6bf |
jr->command = obstack_alloc(&tab_o, command_len + 1);
|
|
|
96d6bf |
+ if (jr->command == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
strcpy(jr->command, command);
|
|
|
96d6bf |
jr->job_pid = jr->mailer_pid = 0;
|
|
|
96d6bf |
if (last_job_rec != NULL) last_job_rec->next = jr;
|
|
|
96d6bf |
@@ -208,6 +228,9 @@
|
|
|
96d6bf |
}
|
|
|
96d6bf |
|
|
|
96d6bf |
jr = obstack_alloc(&tab_o, sizeof(job_rec));
|
|
|
96d6bf |
+ if (jr == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
if (!strncmp ("@monthly", periods, 8)) {
|
|
|
96d6bf |
jr->named_period = 1;
|
|
|
96d6bf |
} else if (!strncmp("@yearly", periods, 7) || !strncmp("@annually", periods, 9) || !strncmp(/* backwards compat misspelling */"@annualy", periods, 8)) {
|
|
|
96d6bf |
@@ -225,9 +248,15 @@
|
|
|
96d6bf |
jr->delay = delay;
|
|
|
96d6bf |
jr->tab_line = line_num;
|
|
|
96d6bf |
jr->ident = obstack_alloc(&tab_o, ident_len + 1);
|
|
|
96d6bf |
+ if (jr->ident == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
strcpy(jr->ident, ident);
|
|
|
96d6bf |
jr->arg_num = job_arg_num(ident);
|
|
|
96d6bf |
jr->command = obstack_alloc(&tab_o, command_len + 1);
|
|
|
96d6bf |
+ if (jr->command == NULL) {
|
|
|
96d6bf |
+ die_e("Cannot allocate memory.");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
strcpy(jr->command, command);
|
|
|
96d6bf |
jr->job_pid = jr->mailer_pid = 0;
|
|
|
96d6bf |
if (last_job_rec != NULL) last_job_rec->next = jr;
|
|
|
96d6bf |
diff -ru cronie-1.5.2/anacron/runjob.c cronie-1.5.2_patched/anacron/runjob.c
|
|
|
96d6bf |
--- cronie-1.5.2/anacron/runjob.c 2018-01-24 17:02:33.000000000 +0100
|
|
|
96d6bf |
+++ cronie-1.5.2_patched/anacron/runjob.c 2018-09-07 15:13:17.752498050 +0200
|
|
|
96d6bf |
@@ -104,9 +104,44 @@
|
|
|
96d6bf |
static void
|
|
|
96d6bf |
xputenv(const char *s)
|
|
|
96d6bf |
{
|
|
|
96d6bf |
- char *copy = strdup (s);
|
|
|
96d6bf |
- if (!copy) die_e("Not enough memory to set the environment");
|
|
|
96d6bf |
- if (putenv(copy)) die_e("Can't set the environment");
|
|
|
96d6bf |
+ char *name = NULL, *val = NULL;
|
|
|
96d6bf |
+ char *eq_ptr;
|
|
|
96d6bf |
+ const char *errmsg;
|
|
|
96d6bf |
+ size_t eq_index;
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ if (s == NULL) {
|
|
|
96d6bf |
+ die_e("Invalid environment string");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ eq_ptr = strchr(s, '=');
|
|
|
96d6bf |
+ if (eq_ptr == NULL) {
|
|
|
96d6bf |
+ die_e("Invalid environment string");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ eq_index = (size_t) (eq_ptr - s);
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ name = malloc((eq_index + 1) * sizeof(char));
|
|
|
96d6bf |
+ if (name == NULL) {
|
|
|
96d6bf |
+ die_e("Not enough memory to set the environment");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ val = malloc((strlen(s) - eq_index) * sizeof(char));
|
|
|
96d6bf |
+ if (val == NULL) {
|
|
|
96d6bf |
+ die_e("Not enough memory to set the environment");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ strncpy(name, s, eq_index);
|
|
|
96d6bf |
+ name[eq_index] = '\0';
|
|
|
96d6bf |
+ strcpy(val, s + eq_index + 1);
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ if (setenv(name, val, 1)) {
|
|
|
96d6bf |
+ die_e("Can't set the environment");
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
+
|
|
|
96d6bf |
+ free(name);
|
|
|
96d6bf |
+ free(val);
|
|
|
96d6bf |
+ return;
|
|
|
96d6bf |
+
|
|
|
96d6bf |
}
|
|
|
96d6bf |
|
|
|
96d6bf |
static void
|
|
|
96d6bf |
diff -ru cronie-1.5.2/src/entry.c cronie-1.5.2_patched/src/entry.c
|
|
|
96d6bf |
--- cronie-1.5.2/src/entry.c 2017-09-14 13:53:21.000000000 +0200
|
|
|
96d6bf |
+++ cronie-1.5.2_patched/src/entry.c 2018-09-07 15:13:17.752498050 +0200
|
|
|
96d6bf |
@@ -131,8 +131,10 @@
|
|
|
96d6bf |
goto eof;
|
|
|
96d6bf |
}
|
|
|
96d6bf |
ch = get_char(file);
|
|
|
96d6bf |
- if (ch == EOF)
|
|
|
96d6bf |
+ if (ch == EOF) {
|
|
|
96d6bf |
+ free(e);
|
|
|
96d6bf |
return NULL;
|
|
|
96d6bf |
+ }
|
|
|
96d6bf |
}
|
|
|
96d6bf |
|
|
|
96d6bf |
if (ch == '@') {
|