1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

util.c: check if return value from ttyname_r is > 0 instead of != 0

We must return a negative error code from getttyname_malloc but
that would not be the case if ttyname_r returned a negative value.

ttyname_r should only return EBADF, ENOTTY, or ERANGE so it should
be safe to change.
This commit is contained in:
Thomas Hindoe Paaboel Andersen 2013-11-30 23:45:31 +01:00
parent a051da35ce
commit 27373e4427
Notes: Zbigniew Jędrzejewski-Szmek 2013-12-03 18:46:51 -05:00
Backport: bugfix

View File

@ -2501,7 +2501,7 @@ int getttyname_malloc(int fd, char **r) {
assert(r);
k = ttyname_r(fd, path, sizeof(path));
if (k != 0)
if (k > 0)
return -k;
char_array_0(path);