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