[vlc-commits] [Git][videolan/vlc][master] 3 commits: access: vnc: handle NDEBUG assert check

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Apr 9 16:02:50 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
2b2b4717 by François Cartegnie at 2026-04-09T15:37:12+00:00
access: vnc: handle NDEBUG assert check

assert does not prevent of anything

- - - - -
4c11606b by François Cartegnie at 2026-04-09T15:37:12+00:00
access: vnc: fix potential overflow

mul_overflow parameter could also overflow before check

- - - - -
e042b328 by François Cartegnie at 2026-04-09T15:37:12+00:00
access: vnc: check es

- - - - -


1 changed file:

- modules/access/vnc.c


Changes:

=====================================
modules/access/vnc.c
=====================================
@@ -34,6 +34,7 @@
 # include "config.h"
 #endif
 #include <assert.h>
+#include <limits.h>
 
 #include <vlc_common.h>
 #include <vlc_threads.h>
@@ -147,11 +148,14 @@ static rfbBool mallocFrameBufferHandler( rfbClient* p_client )
         p_sys->es = NULL;
     }
 
-    assert(!(p_client->width & ~0xffff)); // fits in 16 bits
-    uint16_t i_width = p_client->width;
-
-    assert(!(p_client->height & ~0xffff)); // fits in 16 bits
-    uint16_t i_height = p_client->height;
+    if ( p_client->width > UINT16_MAX || p_client->height > UINT16_MAX )
+    {
+        assert(p_client->width <= UINT16_MAX); // fits in 16 bits
+        assert(p_client->height <= UINT16_MAX); // fits in 16 bits
+        return FALSE;
+    }
+    unsigned int i_width = p_client->width;
+    unsigned int i_height = p_client->height;
 
     if (p_client->format.depth <= 8 &&
             !strstr(p_client->appData.encodingsString, "tight")) // libvnc does not support tight at 8 bpp
@@ -197,7 +201,8 @@ static rfbBool mallocFrameBufferHandler( rfbClient* p_client )
     }
 
     /* Set up framebuffer */
-    if (mul_overflow(i_width, i_height * (p_client->format.bitsPerPixel / 8), &p_sys->i_framebuffersize)) {
+    if (mul_overflow(i_height, p_client->format.bitsPerPixel / 8, &p_sys->i_framebuffersize) ||
+        mul_overflow(i_width, p_sys->i_framebuffersize, &p_sys->i_framebuffersize)) {
         msg_Err(p_demux, "VNC framebuffersize overflow");
         return FALSE;
     }
@@ -370,7 +375,8 @@ static void *DemuxThread( void *p_data )
             if ( ! i_status )
             {
                 msg_Warn( p_demux, "Cannot get announced data. Server closed ?" );
-                es_out_Del( p_demux->out, p_sys->es );
+                if ( p_sys->es )
+                    es_out_Del( p_demux->out, p_sys->es );
                 p_sys->es = NULL;
                 return NULL;
             }
@@ -381,7 +387,10 @@ static void *DemuxThread( void *p_data )
                 {
                     p_sys->p_block->i_dts = p_sys->p_block->i_pts = vlc_tick_now();
                     es_out_SetPCR( p_demux->out, p_sys->p_block->i_pts );
-                    es_out_Send( p_demux->out, p_sys->es, p_sys->p_block );
+                    if ( p_sys->es )
+                        es_out_Send( p_demux->out, p_sys->es, p_sys->p_block );
+                    else
+                        block_Release( p_sys->p_block );
                     p_sys->p_block = p_block;
                 }
             }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/93f0d7291ed03fd0798704549ececf12d981e304...e042b3285bdfae28417da27ec341c9266a91e89c

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




More information about the vlc-commits mailing list