Blob Blame History Raw
From 05175fd678f6f7f09ff9543cd11bbd7ebf14fe58 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Sat, 30 Nov 2013 23:45:31 +0100
Subject: [PATCH] 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.
---
 src/shared/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index 3fc080a..1510c5e 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2561,7 +2561,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);