2014-10-14 18:30:43 +02:00
|
|
|
Based on 6f53e671aa7539cab02c9f739d84d28a343ca5bc Mon Sep 17 00:00:00 2001
|
|
|
|
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
|
|
|
Date: Wed, 8 Oct 2014 23:57:32 +0200
|
|
|
|
Subject: [PATCH] util: avoid double close of fd
|
|
|
|
|
|
|
|
We could end with a double close if we close the fd loop and flush_fd
|
|
|
|
fails. That would make us goto fail and there we close the fd once
|
|
|
|
again. This patch sets the fd to the return value for safe_close: -1
|
|
|
|
A fd with negative value will be ignored by the next call to
|
|
|
|
safe_close.
|
|
|
|
|
|
|
|
CID#996223
|
|
|
|
---
|
2014-10-30 15:13:42 +01:00
|
|
|
src/shared/util.c | 3 ++-
|
|
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
2014-10-14 18:30:43 +02:00
|
|
|
|
|
|
|
--- src/shared/util.c
|
|
|
|
+++ src/shared/util.c 2014-10-14 15:42:22.515839157 +0000
|
2014-10-30 15:13:42 +01:00
|
|
|
@@ -1969,7 +1969,8 @@ int acquire_terminal(
|
|
|
|
* ended our handle will be dead. It's important that
|
2014-10-14 18:30:43 +02:00
|
|
|
* we do this after sleeping, so that we don't enter
|
|
|
|
* an endless loop. */
|
2014-10-30 15:13:42 +01:00
|
|
|
- close_nointr_nofail(fd);
|
|
|
|
+ if (fd >= 0) close_nointr_nofail(fd);
|
2014-10-14 18:30:43 +02:00
|
|
|
+ fd = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notify >= 0)
|