[vlc-devel] [vlc-commits] hls: Avoid using errno.

Hugo Beauzée-Luyssen beauze.h at gmail.com
Mon Mar 12 15:07:53 CET 2012


On Mon, Mar 12, 2012 at 3:00 PM, Hugo Beauzée-Luyssen
<beauze.h at gmail.com> wrote:
> 2012/3/12 Rémi Denis-Courmont <remi at remlab.net>:
>> On Fri,  9 Mar 2012 16:37:41 +0100 (CET), git at videolan.org (Hugo
>> Beauzée-Luyssen) wrote:
>>> vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri
>> Mar
>>> 9 16:34:59 2012 +0100| [7eb141b4800273870a95210a98c6464416a3b041] |
>>> committer: Hugo Beauzée-Luyssen
>>>
>>> hls: Avoid using errno.
>>>
>>>>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7eb141b4800273870a95210a98c6464416a3b041
>>> ---
>>>
>>>  modules/stream_filter/httplive.c |    9 +++++----
>>>  1 files changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/modules/stream_filter/httplive.c
>>> b/modules/stream_filter/httplive.c
>>> index f13c568..f9eba12 100644
>>> --- a/modules/stream_filter/httplive.c
>>> +++ b/modules/stream_filter/httplive.c
>>> @@ -574,10 +574,11 @@ static int parse_SegmentInformation(hls_stream_t
>>> *hls, char *p_read, int *durati
>>>          return VLC_EGENERIC;
>>>
>>>      int value;
>>> +    char *endptr;
>>>      if (hls->version < 3)
>>>      {
>>> -       value = strtol(token, NULL, 10);
>>> -       if (errno == ERANGE)
>>> +       value = strtol(token, &endptr, 10);
>>> +       if (token == endptr)
>>
>> This does not look correct to me.
>>
>> --
>> Rémi Denis-Courmont
>> Sent from my collocated server
>
> You are right, this doesn't check for overflow nor underflow.
> I will fix it ASAP.
>
> Regards,
>
> --
> Hugo Beauzée-Luyssen

This should be a clean solution. However, Since I remember you had
objections about using errno in the past, I'd like a feedback first.
IIRC your objection was about using %m which isn't thread safe in GNU
libc, but still, better safe than sorry.

Regards,

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index b4ed58d..084be68 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -34,6 +34,7 @@
 #include <vlc_plugin.h>

 #include <assert.h>
+#include <errno.h>
 #include <gcrypt.h>

 #include <vlc_threads.h>
@@ -577,7 +578,7 @@ static int parse_SegmentInformation(hls_stream_t
*hls, char *p_read, int *durati
     if (hls->version < 3)
     {
        value = strtol(token, &endptr, 10);
-       if (token == endptr)
+       if (token == endptr || errno == ERANGE )
        {
            *duration = -1;
            return VLC_EGENERIC;
@@ -587,7 +588,7 @@ static int parse_SegmentInformation(hls_stream_t
*hls, char *p_read, int *durati
     else
     {
         double d = strtof(token, &endptr);
-        if (token == endptr)
+        if (token == endptr || errno == ERANGE )
         {
             *duration = -1;
             return VLC_EGENERIC;
-- 
Hugo Beauzée-Luyssen



More information about the vlc-devel mailing list