diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-08-09 19:03:39 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-09-25 14:31:04 +0200 |
commit | d1c1c992b810520323ddbceca865ba8995f1dd95 (patch) | |
tree | d08f8b7821746419d63ce5956661c0ae4a6b693c /src | |
parent | 1af2863f2cc977ecc0bcbde641191627fc07a9f1 (diff) |
tree-wide: use path_startswith() rather than startswith() where ever that's appropriate
When checking path prefixes we really should use the right APIs, just in
case people add multiple slashes to their paths...
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/terminal-util.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 37da0b192..11597d085 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -561,6 +561,7 @@ int terminal_vhangup(const char *name) { int vt_disallocate(const char *name) { _cleanup_close_ int fd = -1; + const char *e, *n; unsigned u; int r; @@ -568,7 +569,8 @@ int vt_disallocate(const char *name) { * (i.e. because it is the active one), at least clear it * entirely (including the scrollback buffer) */ - if (!startswith(name, "/dev/")) + e = path_startswith(name, "/dev/"); + if (!e) return -EINVAL; if (!tty_is_vc(name)) { @@ -587,10 +589,11 @@ int vt_disallocate(const char *name) { return 0; } - if (!startswith(name, "/dev/tty")) + n = startswith(e, "tty"); + if (!n) return -EINVAL; - r = safe_atou(name+8, &u); + r = safe_atou(n, &u); if (r < 0) return r; |