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

Balazs Scheidler bazsi at balabit.hu
Sat May 28 13:57:14 CEST 2011


Hi,

Can you please explain when this causes problems and what the problem
is? Does it perhaps need to be backported to earlier versions?

Also, some sanity check on raw_buffer_size would be needed, as we try to
allocate that size from the stack, which is limited in size.

On Mon, 2011-05-23 at 11:56 +0200, Gergely Nagy wrote:
> 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

-- 
Bazsi




More information about the syslog-ng mailing list