From 641f4a885f141b8350076c9293ebd971dc984347 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 30 May 2012 17:35:05 +0300 Subject: tcp: Check the return values from bind and accept MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/tcp.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libavformat/tcp.c') diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 37f74f6e2f..e249e4e830 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -84,8 +84,16 @@ static int tcp_open(URLContext *h, const char *uri, int flags) if (listen_socket) { int fd1; ret = bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen); + if (ret) { + ret = ff_neterrno(); + goto fail1; + } listen(fd, 1); fd1 = accept(fd, NULL, NULL); + if (fd1 < 0) { + ret = ff_neterrno(); + goto fail1; + } closesocket(fd); fd = fd1; ff_socket_nonblock(fd, 1); -- cgit v1.2.3