Skip to content

make_filter_str bug (solution proposed) #1

Description

@N00TN00T

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions