[syslog-ng] [PATCH 1/7] [persist]: only check the buffer size if no encoding is specified

Gergely Nagy algernon at balabit.hu
Mon May 23 11:56:09 CEST 2011


From: Peter Gyorko <gyorkop at balabit.hu>

If no encoding is specified, we read directly into our buffer,
therefore need to verify the buffer sizes. If we do use encoding, the
raw buffer size cannot be directly compared to our own buffer size.

Therefore, only validate the buffer size if no encoding is specified,
because otherwise it doesn't make sense.

Signed-off-by: Viktor Juhasz <jviktor at balabit.hu>
Signed-off-by: Peter Gyorko <gyorkop at balabit.hu>
---
 lib/logproto.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/logproto.c b/lib/logproto.c
index d526357..6e81892 100644
--- a/lib/logproto.c
+++ b/lib/logproto.c
@@ -651,16 +651,16 @@ log_proto_buffered_server_apply_state(LogProtoBufferedServer *self, PersistEntry
       gssize rc;
       guchar *raw_buffer;
 
-      if (state->raw_buffer_size > state->buffer_size)
-        {
-          msg_notice("Invalid raw_buffer_size member in LogProtoBufferedServer state, restarting from the beginning",
-                     evt_tag_str("state", persist_name),
-                     NULL);
-          goto error;
-        }
       if (!self->super.encoding)
         {
           /* no conversion, we read directly into our buffer */
+          if (state->raw_buffer_size > state->buffer_size)
+            {
+              msg_notice("Invalid raw_buffer_size member in LogProtoBufferedServer state, restarting from the beginning",
+                         evt_tag_str("state", persist_name),
+                         NULL);
+              goto error;
+            }
           raw_buffer = self->buffer;
         }
       else
-- 
1.7.2.5



More information about the syslog-ng mailing list