path validation: char is not signed by default.#4805
Conversation
ARM treats its `char` type as `unsigned type` by default; as a result, testing a `char` value as being `< 0` is always false. This is a warning on ARM, which is promoted to an error given our use of `-Werror`. Per ISO 9899:199, section "6.2.5 Types": > The three types char, signed char, and unsigned char are collectively > called the character types. The implementation shall define char to > have the same range, representation, and behavior as either signed > char or unsigned char. > ... > Irrespective of the choice made, char is a separate type from the other > two and is not compatible with either.
|
Note that this whole test seems rather pointless anyway, since the test immediately following it will return true for any instance where this test also returns true. Is the thinking that the tolower test is more expensive and we could skip it for bytes outside the ASCII range? If so, I would argue that most filenames are mostly ASCII so we've added a test to this loop that will rarely actually catch anything, making the loop more expensive overall. So my inclination is to actually remove this test entirely. |
|
/cc @carlosmn in case I'm missing something. |
|
One place where we'd go above 127 is for the special chars in ASCII, like accented vowels and other "European" characters. I think we probably only ever get UTF-8 here, but since we're looking at individual bytes, we might get one with a continuation here. The code in git says which I guess makes sense, maybe, though I'm not sure what Other than that, I guess we'd avoid hitting |
|
OK, I think the bigger issue was that I wanted to make sure that I had understood the problem that you were trying to solve. I think that you're right that we shouldn't try to divine what |
|
I think I would slightly favour |
|
Personally, I think that the |
ARM treats its
chartype asunsigned typeby default; as a result, testing acharvalue as being< 0is always false. This is a warning on ARM, which is promoted to an error given our use of-Werror.Per ISO 9899:199, section "6.2.5 Types":
...