Hello,

Joan Lledó, le dim. 19 avril 2026 11:16:49 +0200, a ecrit:
> `put_cmsg` assumes a `msg_controllen` of `2048` and, for each flag set in the 
> socket, substracts the corresponding size from `msg_controllen`. Due to that, 
> this line in pfinet was wrong:
> 
> ```c
> *controllen = m.msg_controllen;
> ```
> 
> It was setting `*controllen` to `2048` when no flags, and `2024` when flag is 
> `IP_PKTINFO`. But it should set the value to the actual amount of bytes 
> written in the control block instead. That is, `0` and `24`.

Ah, right, msg_controllen is the remaining size, not the filled size.

> On the other hand, something that really confuses me is that, in the previous 
> scenario where garbage was being returned to the client, I found that the 
> garbage was in fact valid control block data from previous calls. Does this 
> make sense? is the same memory buffer being reused between calls?

Be it on the stack or from the heap, memory is reused as such, sure.

Samuel

Reply via email to