Skip to content

Commit

Permalink
Control character and non-printables check
Browse files Browse the repository at this point in the history
Added a check for non-printables and control characters, to return -1 (in "err") if found.
  • Loading branch information
tomspiderlabs committed Mar 28, 2023
1 parent 53a4bda commit c5dc264
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/fields.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* The supplied field is scanned for non-printable and other illegal
* characters.
* + -1 is returned if an illegal character is present.
* + 1 is returned if no illegal characters are present, but the field
* contains a non-printable character.
* + -1 is returned if no illegal characters are present, but the field
* contains non-printables or control characters.
* + 0 is returned otherwise.
*/
int valid_field (const char *field, const char *illegal)
Expand All @@ -43,12 +43,12 @@ int valid_field (const char *field, const char *illegal)
break;
}
}

if (0 == err) {
/* Search if there are some non-printable characters */
/* Search if there are non-printables or control characters */
for (cp = field; '\0' != *cp; cp++) {
if (!isprint (*cp)) {
err = 1;
if (!isprint(*cp) || !iscntrl(*cp)) {
err = -1;
break;
}
}
Expand Down

0 comments on commit c5dc264

Please sign in to comment.