|
Zbigniew Jędrzejewski-Szmek |
d66047 |
From 05175fd678f6f7f09ff9543cd11bbd7ebf14fe58 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
Date: Sat, 30 Nov 2013 23:45:31 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
Subject: [PATCH] util.c: check if return value from ttyname_r is > 0 instead
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
of != 0
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
We must return a negative error code from getttyname_malloc but
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
that would not be the case if ttyname_r returned a negative value.
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
ttyname_r should only return EBADF, ENOTTY, or ERANGE so it should
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
be safe to change.
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
src/shared/util.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
diff --git a/src/shared/util.c b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
index 3fc080a..1510c5e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
--- a/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
+++ b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
@@ -2561,7 +2561,7 @@ int getttyname_malloc(int fd, char **r) {
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
assert(r);
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
k = ttyname_r(fd, path, sizeof(path));
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
- if (k != 0)
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
+ if (k > 0)
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
return -k;
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
|
|
Zbigniew Jędrzejewski-Szmek |
d66047 |
char_array_0(path);
|