Jordi Ortiz | 16 Jun 2012 12:29
Picon

[PATCH 1/3] TCP: check listen()

---
 libavformat/tcp.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index a6eeeb0..7e348f7 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
 <at>  <at>  -90,7 +90,11  <at>  <at>  static int tcp_open(URLContext *h, const char *uri, int flags)
             ret = ff_neterrno();
             goto fail1;
         }
-        listen(fd, 1);
+        ret = listen(fd, 1);
+        if (ret) {
+            ret = ff_neterrno();
+            goto fail1;
+        }
         fd1 = accept(fd, NULL, NULL);
         if (fd1 < 0) {
             ret = ff_neterrno();
--

-- 
1.7.10

Samuel Pitoiset | 16 Jun 2012 12:52
Picon

Re: [PATCH 1/3] TCP: check listen()

On Sat, Jun 16, 2012 at 12:29 PM, Jordi Ortiz <nenjordi@...> wrote:
> ---
>  libavformat/tcp.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index a6eeeb0..7e348f7 100644
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
>  <at>  <at>  -90,7 +90,11  <at>  <at>  static int tcp_open(URLContext *h, const char *uri, int flags)
>             ret = ff_neterrno();
>             goto fail1;
>         }
> -        listen(fd, 1);
> +        ret = listen(fd, 1);
> +        if (ret) {
> +            ret = ff_neterrno();
> +            goto fail1;
> +        }

I think listen() should return -1 in case of failure...

>         fd1 = accept(fd, NULL, NULL);
>         if (fd1 < 0) {
>             ret = ff_neterrno();
> --
> 1.7.10
>
> _______________________________________________
> libav-devel mailing list
(Continue reading)

Martin Storsjö | 16 Jun 2012 21:13

Re: [PATCH 1/3] TCP: check listen()

On Sat, 16 Jun 2012, Samuel Pitoiset wrote:

> On Sat, Jun 16, 2012 at 12:29 PM, Jordi Ortiz <nenjordi@...> wrote:
>> ---
>>  libavformat/tcp.c |    6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
>> index a6eeeb0..7e348f7 100644
>> --- a/libavformat/tcp.c
>> +++ b/libavformat/tcp.c
>>  <at>  <at>  -90,7 +90,11  <at>  <at>  static int tcp_open(URLContext *h, const char *uri, int flags)
>>             ret = ff_neterrno();
>>             goto fail1;
>>         }
>> -        listen(fd, 1);
>> +        ret = listen(fd, 1);
>> +        if (ret) {
>> +            ret = ff_neterrno();
>> +            goto fail1;
>> +        }
>
> I think listen() should return -1 in case of failure...

Yes, listen returns 0 on success and -1 on failure. If ret == 0, it will 
not hit the error case, but ret == -1 will trigger "if (ret)". The bind() 
call above has the same semantics and the same kind of error checking.

// Martin
(Continue reading)

Martin Storsjö | 16 Jun 2012 21:13

Re: [PATCH 1/3] TCP: check listen()

On Sat, 16 Jun 2012, Jordi Ortiz wrote:

> ---
> libavformat/tcp.c |    6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index a6eeeb0..7e348f7 100644
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
>  <at>  <at>  -90,7 +90,11  <at>  <at>  static int tcp_open(URLContext *h, const char *uri, int flags)
>             ret = ff_neterrno();
>             goto fail1;
>         }
> -        listen(fd, 1);
> +        ret = listen(fd, 1);
> +        if (ret) {
> +            ret = ff_neterrno();
> +            goto fail1;
> +        }
>         fd1 = accept(fd, NULL, NULL);
>         if (fd1 < 0) {
>             ret = ff_neterrno();
> -- 
> 1.7.10

LGTM

// Martin
(Continue reading)

Jordi Ortiz | 17 Jun 2012 10:10
Picon

Re: [PATCH 1/3] TCP: check listen()


LGTM

Should I resend the patch without the 1/3 on the subject email? Sorry for that, didn't notice until now.

Jordi
<div>
<div class="gmail_quote"><blockquote class="gmail_quote">
<div class="HOEnZb"><div class="h5">
<br>
</div></div>
LGTM<span class="HOEnZb"><br></span><br>
</blockquote></div>Should I resend the patch without the 1/3 on the subject email? Sorry for that, didn't notice until now.<br><br>Jordi<br>
</div>
Martin Storsjö | 17 Jun 2012 11:44

Re: [PATCH 1/3] TCP: check listen()

On Sun, 17 Jun 2012, Jordi Ortiz wrote:

> Should I resend the patch without the 1/3 on the subject email? Sorry for
> that, didn't notice until now.

No, that's not necessary, it's stripped out when applied anyway.

// Martin

Gmane