mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-06 21:51:37 +00:00
util: consider 0x7F a control chracter (which it is: DEL)
Let's better be safe than sorry. (cherry picked from commit3a8a916338) (cherry picked from commita71b7b7e52)
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
a2bdf1cc14
commit
3fe476cebb
+10
-2
@@ -1716,8 +1716,9 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
|
||||
if (fd_wait_for_event(fileno(f), POLLIN, t) <= 0)
|
||||
return -ETIMEDOUT;
|
||||
|
||||
errno = 0;
|
||||
if (!fgets(line, sizeof(line), f))
|
||||
return -EIO;
|
||||
return errno ? -errno : -EIO;
|
||||
|
||||
truncate_nl(line);
|
||||
|
||||
@@ -5344,6 +5345,9 @@ bool string_is_safe(const char *p) {
|
||||
if (*t > 0 && *t < ' ')
|
||||
return false;
|
||||
|
||||
if (*t == 127)
|
||||
return false;
|
||||
|
||||
if (strchr("\\\"\'", *t))
|
||||
return false;
|
||||
}
|
||||
@@ -5360,10 +5364,14 @@ bool string_has_cc(const char *p) {
|
||||
|
||||
assert(p);
|
||||
|
||||
for (t = p; *t; t++)
|
||||
for (t = p; *t; t++) {
|
||||
if (*t > 0 && *t < ' ' && *t != '\t')
|
||||
return true;
|
||||
|
||||
if (*t == 127)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user