projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
500f5be
)
fix possible fd leak, unrestored cancellation state on dns socket fail
author
Rich Felker
<dalias@aerifal.cx>
Tue, 14 Mar 2017 18:31:34 +0000
(14:31 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Tue, 14 Mar 2017 18:31:34 +0000
(14:31 -0400)
src/network/res_msend.c
patch
|
blob
|
history
diff --git
a/src/network/res_msend.c
b/src/network/res_msend.c
index de7f615762e72b577ebc09c48363fad8ac27fb44..3e018009ebc61e10c3eb24e0e6039e8fac5e01c4 100644
(file)
--- a/
src/network/res_msend.c
+++ b/
src/network/res_msend.c
@@
-76,7
+76,11
@@
int __res_msend_rc(int nqueries, const unsigned char *const *queries,
fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
family = AF_INET;
}
- if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) return -1;
+ if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) {
+ if (fd >= 0) close(fd);
+ pthread_setcancelstate(cs, 0);
+ return -1;
+ }
/* Past this point, there are no errors. Each individual query will
* yield either no reply (indicated by zero length) or an answer