[vlc-commits] [Git][videolan/vlc][master] 4 commits: http: fix handling of 0 bytes HTTP/2 payloads

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Sep 28 16:58:59 UTC 2021



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
fc9001d0 by Rémi Denis-Courmont at 2021-09-28T16:38:59+00:00
http: fix handling of 0 bytes HTTP/2 payloads

If size is 0 and EOS is true, then base may be NULL.
(base + size) is then UB.

- - - - -
2f66f821 by Rémi Denis-Courmont at 2021-09-28T16:38:59+00:00
http: fix formatting 0-byte data frame

If len is zero, then buf may be NULL and cannot be passed as second
parameter to memcpy().

- - - - -
e37b6421 by Rémi Denis-Courmont at 2021-09-28T16:38:59+00:00
config: fix UB on configuration-less modules

If a conf.size is 0, then conf.items will be NULL so
the expression (conf.items + conf.size) is undefined.

- - - - -
f275e555 by Rémi Denis-Courmont at 2021-09-28T16:38:59+00:00
lua: do not compute NULL+0

- - - - -


5 changed files:

- modules/access/http/h2conn.c
- modules/access/http/h2frame.c
- modules/lua/vlc.c
- src/config/cmdline.c
- src/config/core.c


Changes:

=====================================
modules/access/http/h2conn.c
=====================================
@@ -354,7 +354,8 @@ static ssize_t vlc_h2_stream_write(struct vlc_http_stream *stream,
             break;
         }
 
-        base = (const char *)base + size;
+        if (likely(size > 0))
+            base = (const char *)base + size;
         length -= size;
         total += size;
         s->send_cwnd -= size;


=====================================
modules/access/http/h2frame.c
=====================================
@@ -232,7 +232,7 @@ vlc_h2_frame_data(uint_fast32_t stream_id, const void *buf, size_t len,
     uint8_t flags = eos ? VLC_H2_DATA_END_STREAM : 0;
 
     f = vlc_h2_frame_alloc(VLC_H2_FRAME_DATA, flags, stream_id, len);
-    if (likely(f != NULL))
+    if (len > 0 && likely(f != NULL))
         memcpy(vlc_h2_frame_payload(f), buf, len);
     return f;
 }


=====================================
modules/lua/vlc.c
=====================================
@@ -250,7 +250,7 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
         msg_Dbg( p_this, "Trying Lua scripts in %s", *ppsz_dir );
         int i_files = vlc_scandir( *ppsz_dir, &ppsz_filelist, file_select,
                                    file_compare );
-        if( i_files < 0 )
+        if( i_files <= 0 )
             continue;
 
         char **ppsz_file = ppsz_filelist;


=====================================
src/config/cmdline.c
=====================================
@@ -114,11 +114,10 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
     i_index = 0;
     for (const vlc_plugin_t *p = vlc_plugins; p != NULL; p = p->next)
     {
-        for (const module_config_t *p_item = p->conf.items,
-                                   *p_end = p_item + p->conf.size;
-             p_item < p_end;
-             p_item++)
+        for (size_t i = 0; i < p->conf.size; i++)
         {
+            const module_config_t *p_item = p->conf.items + i;
+
             /* Ignore hints */
             if( !CONFIG_ITEM(p_item->i_type) )
                 continue;


=====================================
src/config/core.c
=====================================
@@ -419,12 +419,10 @@ int config_SortConfig (void)
     size_t index = 0;
     for (p = vlc_plugins; p != NULL; p = p->next)
     {
-        module_config_t *item, *end;
-
-        for (item = p->conf.items, end = item + p->conf.size;
-             item < end;
-             item++)
+        for (size_t i = 0; i < p->conf.size; i++)
         {
+            module_config_t *item = p->conf.items + i;
+
             if (!CONFIG_ITEM(item->i_type))
                 continue; /* ignore hints */
             assert(index < nconf);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2dd4eb2d834906a99a36d1a27c7044b85d9ed2f4...f275e5551f91b0359c1b620857a8e06e95a3d0c1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2dd4eb2d834906a99a36d1a27c7044b85d9ed2f4...f275e5551f91b0359c1b620857a8e06e95a3d0c1
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list