diff --git a/include/ilib/template.h b/include/ilib/template.h
index 853fd40..4975105 100644
--- a/include/ilib/template.h
+++ b/include/ilib/template.h
@@ -1,12 +1,31 @@
-/* template.h - Template parser and string variable substitution engine */
+/*
+ * this is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * this is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .";
+ *
+ * (c) Alexander Vdolainen 2007, 2026
+ * subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
+ *
+ * template.h: expand templates
+ *
+ */
#ifndef __TEMPLATE_H__
#define __TEMPLATE_H__
#include
typedef struct template_var {
- const char *key; /* e.g., "MAILLIST_NAME" (without the '$') */
- const char *val; /* e.g., "Civilisation List" */
+ const char *key;
+ const char *val;
} template_var_t;
/*
diff --git a/src/template.c b/src/template.c
index 5b003b2..f10212a 100644
--- a/src/template.c
+++ b/src/template.c
@@ -1,4 +1,24 @@
-/* template.c - Template substitution implementation */
+/*
+ * this is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * this is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .";
+ *
+ * (c) Alexander Vdolainen 2007, 2026
+ * subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
+ *
+ * template.c: expand templates
+ *
+ */
+
#include
#include
#include
@@ -23,6 +43,9 @@ char *template_render_string(const char *src, const template_var_t *vars, size_t
char *out = malloc(buf_cap);
if (!out) return NULL;
+ if (!src || (var_count > 0 && !vars))
+ return NULL;
+
const char *p = src;
while (*p) {