tcp: Check the return values from bind and accept
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
5f509fa2e1
commit
2dbb8cc6a3
@ -84,8 +84,16 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
|
|||||||
if (listen_socket) {
|
if (listen_socket) {
|
||||||
int fd1;
|
int fd1;
|
||||||
ret = bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
|
ret = bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
|
||||||
|
if (ret) {
|
||||||
|
ret = ff_neterrno();
|
||||||
|
goto fail1;
|
||||||
|
}
|
||||||
listen(fd, 1);
|
listen(fd, 1);
|
||||||
fd1 = accept(fd, NULL, NULL);
|
fd1 = accept(fd, NULL, NULL);
|
||||||
|
if (fd1 < 0) {
|
||||||
|
ret = ff_neterrno();
|
||||||
|
goto fail1;
|
||||||
|
}
|
||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
fd = fd1;
|
fd = fd1;
|
||||||
ff_socket_nonblock(fd, 1);
|
ff_socket_nonblock(fd, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user