Skip to contentSkip to conversation

Fix: Don't create a new packet if ctf_move_pos() seeks out of a packet

PATCH Mathieu Desnoyers 1 participant 1 message Oct 31, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mathieu Desnoyers

author Applied
#1 lore raw

Merged, thanks!

Mathieu

----- Original Message -----

Quoted 63 lines

From: "Jérémie Galarneau" <[email protected]>
To: [email protected]
Sent: Tuesday, October 15, 2013 1:23:46 PM
Subject: [lttng-dev] [PATCH babeltrace] Fix: Don't create a new packet if ctf_move_pos() seeks out of a packet

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.

---
 include/babeltrace/ctf/types.h | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
include/babeltrace/ctf/types.h +0 -17
index 715cdbd..96c5083 100644
@@ -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);

}

include/babeltrace/ctf/types.h +1 -2
@@ -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
--

1.8.4

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 8 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev