Hi Jacek,
Thanks for looking at this.
On Thu, Apr 21, 2022 at 12:13:22PM +0200, Jacek Caban wrote:
- else{
count = max(num_handles * 2, 256);
new_handles = realloc(handles, count);
realloc() size is missing multiplication by sizeof(*handles).
Argh, good catch. I'd even tested this by deliberately leaking handles - I guess I got lucky (or rather, unlucky).
Other than that, the patch looks fine to me. One thing I'd mention for consideration: while proper handle table is the right thing for true kernel interface in general, I'm not sure if we need it in such cases. We could just make the handle 64-bit and use Unix pointer as a value of the handle. It would simplify things, but I can see how such "leak" of Unix pointers may be considered less elegant, so it's fine with me both ways.
Yes, let's go with this. It's simpler, which probably makes sense.
I've sent in v2 with this change and an additional patch to set zero_bits for the Wow64 buffer allocations.
Thanks, Huw.