Fix: Don't create a new packet if ctf_move_pos() seeks out of a packet
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 15 Oct 2013 17:23:46 +0000 (13:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 21 Feb 2014 16:59:52 +0000 (11:59 -0500)
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 <jeremie.galarneau@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/babeltrace/ctf/types.h

index 715cdbd0e182e39f204a4e19aba338ba49265e91..96c5083c2b7d5eea1e0154aa5954073353017139 100644 (file)
@@ -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
This page took 0.027541 seconds and 4 git commands to generate.