From bedf64a9bfdf8fffefd7ced1ea3993a1b5852e6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 15 Oct 2013 13:23:46 -0400 Subject: [PATCH] Fix: Don't create a new packet if ctf_move_pos() seeks out of a packet MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This change ensures that ctf_move_pos() does not create a new packet when ctf_move_pos() moves out of the current packet's bounds. The next call to ctf_pos_access_ok() will report EFAULT which can then be handled appropriately by the caller. Signed-off-by: Jérémie Galarneau Reviewed-by: Mathieu Desnoyers Signed-off-by: Mathieu Desnoyers --- include/babeltrace/ctf/types.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/include/babeltrace/ctf/types.h b/include/babeltrace/ctf/types.h index 715cdbd0..96c5083c 100644 --- a/include/babeltrace/ctf/types.h +++ b/include/babeltrace/ctf/types.h @@ -137,23 +137,6 @@ void ctf_move_pos(struct ctf_stream_pos *pos, uint64_t bit_offset) if (unlikely(pos->offset == EOF)) return; - if (pos->fd >= 0) { - /* - * PROT_READ ctf_packet_seek is called from within - * ctf_pos_get_event so end of packet does not change - * the packet context on for the last event of the - * packet. - */ - if ((pos->prot == PROT_WRITE) - && (unlikely(pos->offset + bit_offset >= pos->packet_size))) { - printf_debug("ctf_packet_seek (before call): %" PRId64 "\n", - pos->offset); - ctf_packet_seek(&pos->parent, 0, SEEK_CUR); - printf_debug("ctf_packet_seek (after call): %" PRId64 "\n", - pos->offset); - return; - } - } pos->offset += bit_offset; printf_debug("ctf_move_pos after increment: %" PRId64 "\n", pos->offset); } @@ -201,7 +184,7 @@ int ctf_pos_packet(struct ctf_stream_pos *dummy) static inline void ctf_pos_pad_packet(struct ctf_stream_pos *pos) { - ctf_move_pos(pos, pos->packet_size - pos->offset); + ctf_packet_seek(&pos->parent, 0, SEEK_CUR); } static inline -- 2.34.1