...
| Code Block | ||
|---|---|---|
| ||
size_t count_whitespace(
char const *s,
size_t length)
{
char const *t = s;
while (isspace((unsigned char)*t) && (t - s < length))
++t;
return t - s;
}
|
Automated Detection
The tool Compass / ROSE could detect violations of this rule by seeing if the argument to a character-handling function (listed above) is not an unsigned char.
Risk Assessment
Passing values to character handling functions that cannot be represented as an unsigned char may result in unintended program behavior.
...