3 May
2011
3 May
'11
9:44 a.m.
Gergely Nagy <algernon@balabit.hu> writes:
From: Gergely Nagy <algernon@madhouse-project.org>
Implement addition, substraction, multiplication, division and modulus template functions: $(+ N M), $(- N M), $(* N M), $(/ N M) and $(% N M), respectively.
Aand, while reviewing this code with Viktor Juhasz, we spotted a mistake in the code below:
+static void +tf_num_div(LogMessage *msg, gint argc, GString *argv[], GString *result) +{ + glong n, m; + + if (!tf_num_parse(argc, argv, "/", &n, &m)) + return; + + g_string_append_printf(result, "%li", (glong)(n / m)); +}
If m is 0, this will crash syslog-ng. I'll repost a version of the patch that guards against this later today. $(/ $FOO 0) will emit an msg_error and do nothing. -- |8]