efficios / barectf

Generator of ANSI C tracers which output CTF data streams
https://barectf.org
MIT License
65 stars 17 forks source link

barectf_packet_set_buf() can change the "full packet" state #18

Closed eepp closed 4 years ago

eepp commented 4 years ago

@jgalar witnessed this.

The condition of barectf_packet_is_full() is

ctx->at == ctx->packet_size

So we're reusing ctx->at to know whether or not a packet is full.

A full packet is always (already) closed.

The problem is that barectf_packet_set_buf() changes ctx->packet_size without touching ctx->at. Therefore if the value of ctx->packet_size changes, and if the packet was considered to be full, it's not the case anymore, but it must be.

The solution is probably to always set ctx->at to ctx->packet_size too in barectf_packet_set_buf().