Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_filter_str bug (solution proposed) #1

Open
N00TN00T opened this issue Jan 10, 2020 · 0 comments
Open

make_filter_str bug (solution proposed) #1

N00TN00T opened this issue Jan 10, 2020 · 0 comments

Comments

@N00TN00T
Copy link

Hey,
Thank you for a simple and useful library!

However, there was a (supposedly) bug that I had to fix for the filter.

The function make_filter_str didn't append the filters to the filter name (i.e. result should be "Executables *.exe;" but it was "Executables")

This is because the byte after 's' in "Executables" was null-terminated ('\0') and when "Executables" is printed to the buffer with this line:

n += sprintf(buf + n, "%s", name) + 1;

n is advanced with the bytes in "Executables" plus the next byte which is '\0'. This means that when the filters are printed to the buffer with the line:

n += sprintf(buf + n, "%s;", b);

They are placed after the null-termination ('\0').

My solution to this is to instead of advancing the pointer offset (n) by 1 after printing the name, you should print the name with a a space byte afterwards like this:

n += sprintf(buf + n, "%s ", name);

instead of the line mentioned above:

n += sprintf(buf + n, "%s", name) + 1;

This will make sure that the byte after the name bytes is 32 (space) and that the filters will be appended before the null termination.

It might be worth mentioning that I am compiling this with a C++ compiler so there might be a slight variation in results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant