From 742a16f5f11f34fa32423bd9b960da7023bdd24e Mon Sep 17 00:00:00 2001
From: Attila Szakacs <attila.szakacs@balabit.com>
Date: Thu, 24 Jan 2019 16:12:01 +0100
Subject: [PATCH] threaded-dest: Fix integer overflow

A negative number's modulo will be negative, which in our
case pointed to a negative entry of the workers array,
causing segfault.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
---
 lib/logthrdestdrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/logthrdestdrv.c b/lib/logthrdestdrv.c
index 8e8dff6c4b..e160e972fc 100644
--- a/lib/logthrdestdrv.c
+++ b/lib/logthrdestdrv.c
@@ -857,7 +857,7 @@ log_threaded_dest_driver_set_max_retries(LogDriver *s, gint max_retries)
 LogThreadedDestWorker *
 _lookup_worker(LogThreadedDestDriver *self, LogMessage *msg)
 {
-  static gint last_worker = 0;
+  static guint last_worker = 0;
 
   gint worker_index = last_worker % self->num_workers;
   last_worker++;
