On Thu, 30 Sep 2021 12:33:58 +0100, Stuart Henderson wrote:
> ----------------------------
> revision 1.628
> date: 2013/11/25 12:52:45; author: benno; state: Exp; lines: +7 -7;
> use u_char for buffers in yylex, for ctype calls
> found by millert@, ok deraadt@
> ----------------------------
Thanks, I had forgotten about that. The issue is that if we have
a char > 127, when that gets assigned to an int it will end up with
the wrong value. Making the buffer unsigned was the least invasive
fix, though perhaps not the best one.
I think adding a cast for things like:
lungetc(*p);
...
c = *--p;
would actually make the intent clearer. E.g.
lungetc((u_char)*p);
...
c = (u_char)*--p;
Since we use casts sparingly, when they are present they indicate
something you need to pay attention to. That is not the case when
we simply change the type.
- todd