yuan-xy / smally

a collection of small programming source files , shell scripts, and config files for linux and windows
1 stars 1 forks source link

Coding issue in the pipelist.cpp #1

Open Therena opened 6 years ago

Therena commented 6 years ago

Hi Yuan,

first of all thanks for the great example to get all the name pipes from the operating system: smally/win32/pipelist.cpp

Unfortunately it is not able to read all the pipes from the system. This is not caused by using some wrong approach to get the pipes, but by having some issues in the code (E.g. in my system are 140 pipes but your code gives me only 60 of them).

Maybe, if time permits, you could rework the code to make your pipe example perfect.

Regards, Therena

zao commented 5 years ago

There is a bug where the last entry in a chunk will not be considered, as the test for NextInfoOffset==0 happens before handling the entry has been processed at https://github.com/yuanxinyu/smally/blob/master/win32/pipelist.cpp#L129-L130.

Moving the test down to above the assignment of the next TmpInfo should fix this.

The writing of the NUL character to the end of the filename also clobbers part of NextInfoOffset, consider copying the name out into a buffer to terminate it instead to avoid corrupting the iteration and possibly cutting it short.

https://stackoverflow.com/a/564201/87969