[lttng-dev] [PATCH babeltrace 1/3] Fix: out-of-bound memory access

Jérémie Galarneau jeremie.galarneau at efficios.com
Fri Feb 12 22:05:38 EST 2016


All three patches have been merged in master. The first fix was also
integrated in stable-1.3.

Thanks!
Jérémie

On Tue, Feb 9, 2016 at 1:27 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> We need to check for end of stream before updating the current packet
> index, else we access memory beyond the last stream packet index array
> element. This fixes valgrind errors which appear at commit
>
> 480ef05 Support ctf index version 1.1
>
> due to change of the element size, but actually caused by commit
>
> 2654fe9 Fix: events discarded timing inaccuracy
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  formats/ctf/ctf.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
> index a617497..37ebdfc 100644
> --- a/formats/ctf/ctf.c
> +++ b/formats/ctf/ctf.c
> @@ -951,6 +951,11 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
>                         assert(0);
>                 }
>
> +               if (pos->cur_index >= pos->packet_index->len) {
> +                       pos->offset = EOF;
> +                       return;
> +               }
> +
>                 packet_index = &g_array_index(pos->packet_index,
>                                 struct packet_index, pos->cur_index);
>                 if (pos->cur_index > 0) {
> @@ -963,11 +968,6 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
>                 ctf_update_current_packet_index(&file_stream->parent,
>                                 prev_index, packet_index);
>
> -               if (pos->cur_index >= pos->packet_index->len) {
> -                       pos->offset = EOF;
> -                       return;
> -               }
> -
>                 /*
>                  * We need to check if we are in trace read or called
>                  * from packet indexing.  In this last case, the
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list