[syslog-ng] [PATCH] loggen: Fix a possible division by zero.
Balazs Scheidler
bazsi at balabit.hu
Tue May 3 23:08:17 CEST 2011
On Mon, 2011-05-02 at 22:17 +0200, Gergely Nagy wrote:
> In some cases where we could not send a single message, loggen tried
> to divide by zero shortly before printing the statistics at the end.
>
> This was trivially reproducible by using -R with a file that contained
> invalid syslog lines.
>
> Signed-off-by: Gergely Nagy <algernon at balabit.hu>
> ---
> tests/loggen/loggen.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/tests/loggen/loggen.c b/tests/loggen/loggen.c
> index bf5d111..c5399a7 100644
> --- a/tests/loggen/loggen.c
> +++ b/tests/loggen/loggen.c
> @@ -467,7 +467,12 @@ gen_messages(send_data_t send_func, void *send_func_ud, int thread_id, FILE *rea
> printf("%d;%lu.%06lu;%.2lf;%lu\n", thread_id, (long) diff_tv.tv_sec, (long) diff_tv.tv_usec, (((double) (count - last_count) * USEC_PER_SEC) / diff_usec), count);
>
> if (readfrom)
> - raw_message_length = sum_linelen/count;
> + {
> + if (count)
> + raw_message_length = sum_linelen/count;
> + else
> + raw_message_length = 0;
> + }
> free(testsdata);
> return count;
> }
Applied to 3.3, thanks.
--
Bazsi
More information about the syslog-ng
mailing list