|
Zbigniew Jędrzejewski-Szmek |
f1004d |
From 6f53e671aa7539cab02c9f739d84d28a343ca5bc Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
Date: Wed, 8 Oct 2014 23:57:32 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
Subject: [PATCH] util: avoid double close of fd
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
We could end with a double close if we close the fd loop and flush_fd
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
fails. That would make us goto fail and there we close the fd once
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
again. This patch sets the fd to the return value for safe_close: -1
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
A fd with negative value will be ignored by the next call to
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
safe_close.
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
CID#996223
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
src/shared/util.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
diff --git a/src/shared/util.c b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
index bbd9bd11d6..5f6249eb04 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
--- a/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
+++ b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
@@ -2074,7 +2074,7 @@ int acquire_terminal(
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
* ended our handle will be dead. It's important that
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
* we do this after sleeping, so that we don't enter
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
* an endless loop. */
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
- safe_close(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
+ fd = safe_close(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
|
|
Zbigniew Jędrzejewski-Szmek |
f1004d |
safe_close(notify);
|