sccn / liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
Other
114 stars 67 forks source link

Fix buffer size calculation in resolve_streams #211

Closed morningf closed 4 months ago

morningf commented 5 months ago

Fix buffer size calculation in resolve_streams and resolve_stream functions. sizeof(buffer) returns the byte size of buffer, not the number of elements it contains. This should be modified to sizeof(buffer) / sizeof(lsl_streaminfo).

cboulay commented 4 months ago

Your fix is correct, thanks!

I guess the idea is that it is possible for the resolver to return more streams than there's room for in the buffer. The code was previously saying that the buffer had room for 8192 resolved stream-info-pointers when in reality it only had room for 1024. So if the resolver ever returned more than 1024 streams this would have caused a problem.

I'm happy to merge this in, but I'm curious, did you try to resolve more than 1024 streams?!

morningf commented 4 months ago

Your fix is correct, thanks!

I guess the idea is that it is possible for the resolver to return more streams than there's room for in the buffer. The code was previously saying that the buffer had room for 8192 resolved stream-info-pointers when in reality it only had room for 1024. So if the resolver ever returned more than 1024 streams this would have caused a problem.

I'm happy to merge this in, but I'm curious, did you try to resolve more than 1024 streams?!

I just want to encapsulate a TypeScript interface for an electron project, so I want to understand the details of these interfaces as much as possible, and thus I discovered this bug. I also think that not really anyone will resolve so many streams.