Commit Graph

5 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 82c68c4a02
wildcard_cmp.c: Fix out-of-bounds cmp
When the distance between '*' on a wildcard expression was larger than
the string to compare with, this would cause an out-of-bounds read
because `n` was not being limited to the strlen(3) from the input
string.

Example:

- s="c", p="*cc*", casecmp=false

Here, the distance between the first and second '*' is 2 bytes, which is
longer than the input string itself (1 byte, not counting the
terminating null byte '\0').
2023-07-09 05:54:56 +02:00
Xavier Del Campo Romero 6adf1c44ad
wildcard_cmp.c: Fix a couple of bugs
wildcard_cmp would otherwise fail with the following use cases:

s = "mymi", p = "*mi*"
s = "mymi", p = "*mi"
2023-06-06 03:48:51 +02:00
Xavier Del Campo Romero 0d7ead4638
wildcard_cmp.c: Remove leftovers
These statements had no effect since it was always executed when
n == 0.
2023-06-06 03:48:51 +02:00
Xavier Del Campo Romero 6e5c001c28
wildcard_cmp: Allow case-insensitive searches
The new search feature will require them.
2023-06-06 03:48:50 +02:00
Xavier Del Campo Romero d4c8a8062f
Split wildcard_cmp into its own component
Future commits will make use of this function outside handler.c.
2023-06-06 03:48:50 +02:00