[vlc-commits] [Git][videolan/vlc][master] 10 commits: demux/avi: only test reading over SSIZE_MAX when it's possible

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jan 13 13:44:38 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
48a64ae6 by Steve Lhomme at 2023-01-13T09:43:31+00:00
demux/avi: only test reading over SSIZE_MAX when it's possible

If ssize_t is the size of an uint32_t or bigger, i_skip which is an unsigned
32-bit cannot be exclusively bigger than SSIZE_MAX.

- - - - -
ad79b5b4 by Steve Lhomme at 2023-01-13T09:43:31+00:00
d3d11_fmt: do not use vararg in macro with fixed parameters

- - - - -
28c80ee4 by Steve Lhomme at 2023-01-13T09:43:31+00:00
avcodec: use ARRAY_SIZE instead of custom code

- - - - -
0c6d4fc8 by Steve Lhomme at 2023-01-13T09:43:31+00:00
adaptive: use vlc_tick_from_sec() for float to vlc_tick conversion

- - - - -
8cf43cea by Steve Lhomme at 2023-01-13T09:43:31+00:00
url: turn #warning into a comment

We properly report an error anyway.

- - - - -
8920df1d by Steve Lhomme at 2023-01-13T09:43:31+00:00
amt: simplify the mem buffer creation

- - - - -
ce225f86 by Steve Lhomme at 2023-01-13T09:43:31+00:00
vlc_es: check the orientation on the enum as an integer

Some compilers may not change the type of the enum into an int automatically
before checking the _Generic variant.

- - - - -
5bbe817a by Steve Lhomme at 2023-01-13T09:43:31+00:00
win32: sensors: use IID_PPV_ARGS with CoCreateInstance()

This is less error prone.

- - - - -
331bb247 by Steve Lhomme at 2023-01-13T09:43:31+00:00
glwin32: add missing LIBCOMCXXFLAGS

It's needed when compiling sensors.cpp.

- - - - -
1e98c09c by Steve Lhomme at 2023-01-13T09:43:31+00:00
http: use the same storage space for const and non const char table

The ch table contain all the same usable n char[2] as the headers table.

- - - - -


12 changed files:

- include/vlc_es.h
- modules/access/amt.c
- modules/access/http/h2frame.c
- modules/codec/avcodec/audio.c
- modules/demux/adaptive/test/playlist/M3U8.cpp
- modules/demux/avi/avi.c
- modules/demux/dash/mpd/IsoffMainParser.cpp
- modules/demux/hls/playlist/Parser.cpp
- modules/video_chroma/d3d11_fmt.c
- modules/video_output/Makefile.am
- modules/video_output/win32/sensors.cpp
- src/text/url.c


Changes:

=====================================
include/vlc_es.h
=====================================
@@ -201,7 +201,7 @@ typedef enum video_orientation_t
 /** Convert enum video_orientation_t to EXIF */
 #define ORIENT_TO_EXIF(orient) ((0x76853421U >> (4 * (orient))) & 15)
 /** If the orientation is natural or mirrored */
-#define ORIENT_IS_MIRROR(orient) parity(orient)
+#define ORIENT_IS_MIRROR(orient) vlc_parity(orient)
 /** If the orientation swaps dimensions */
 #define ORIENT_IS_SWAP(orient) (((orient) & 4) != 0)
 /** Applies horizontal flip to an orientation */


=====================================
modules/access/amt.c
=====================================
@@ -1407,12 +1407,10 @@ static int amt_send_mem_update( stream_t *p_access, bool leave)
     int           i_ipv6_hdr_len = IPv6_HOP_BY_HOP_OPTION_LEN + IPv6_FIXED_HDR_LEN;
     int           i_sendBufSize = i_amt_hdr_len + IP_HDR_IGMP_LEN;
     int           i_sendBufSizeIPv6 = i_amt_hdr_len + i_ipv6_hdr_len + MLD_REPORT_LEN;
-    uint8_t       pSendBuffer[ i_sendBufSize > i_sendBufSizeIPv6 ? i_sendBufSize : i_sendBufSizeIPv6 ]; /* make the buffer as large as needed */
+    char          pSendBuffer[MAC_LEN + NONCE_LEN + AMT_HDR_LEN + IPv6_HOP_BY_HOP_OPTION_LEN + IPv6_FIXED_HDR_LEN + MLD_REPORT_LEN] = { 0 };
     uint32_t      ulNonce = 0;
     access_sys_t *sys = p_access->p_sys;
 
-    memset( pSendBuffer, 0, sizeof(pSendBuffer) );
-
     pSendBuffer[0] = AMT_MEM_UPD;
 
     /* copy relay MAC response */
@@ -1632,8 +1630,7 @@ static bool amt_rcv_relay_adv( stream_t *p_access )
 static bool amt_rcv_relay_mem_query( stream_t *p_access )
 {
     int i_buf_len = RELAY_QUERY_MSG_LEN + AMT_IPV6_MAX_NUM_SOURCES*16;
-    char pkt[i_buf_len];
-    memset( pkt, 0, i_buf_len);
+    char pkt[RELAY_QUERY_MSG_LEN + AMT_IPV6_MAX_NUM_SOURCES*16] = { 0 };
     struct pollfd ufd[1];
     access_sys_t *sys = p_access->p_sys;
 


=====================================
modules/access/http/h2frame.c
=====================================
@@ -540,7 +540,7 @@ static int vlc_h2_parse_headers_end(struct vlc_h2_parser *p)
 
     if (s != NULL)
     {
-        const char *ch[n ? n : 1][2];
+        const char *ch[VLC_H2_MAX_HEADERS][2];
 
         for (int i = 0; i < n; i++)
             ch[i][0] = headers[i][0], ch[i][1] = headers[i][1];


=====================================
modules/codec/avcodec/audio.c
=====================================
@@ -549,7 +549,7 @@ vlc_fourcc_t GetVlcAudioFormat( int fmt )
         [AV_SAMPLE_FMT_FLTP]  = VLC_CODEC_FL32,
         [AV_SAMPLE_FMT_DBLP]  = VLC_CODEC_FL64,
     };
-    if( (sizeof(fcc) / sizeof(fcc[0])) > (unsigned)fmt )
+    if( ARRAY_SIZE(fcc) > (unsigned)fmt )
         return fcc[fmt];
     return VLC_CODEC_S16N;
 }


=====================================
modules/demux/adaptive/test/playlist/M3U8.cpp
=====================================
@@ -493,11 +493,11 @@ int M3U8Playlist_test()
     {
         Expect(m3u);
         Expect(m3u->isLive() == false);
-        Expect(m3u->presentationStartOffset.Get() == ((50 - 11.5) * CLOCK_FREQ));
+        Expect(m3u->presentationStartOffset.Get() == vlc_tick_from_sec(50 - 11.5));
         BaseRepresentation *rep = m3u->getFirstPeriod()->getAdaptationSets().front()->
                                   getRepresentations().front();
         Expect(bufferingLogic.getStartSegmentNumber(rep) == 13);
-        m3u->presentationStartOffset.Set(11.5 * CLOCK_FREQ);
+        m3u->presentationStartOffset.Set(vlc_tick_from_sec(11.5));
         Expect(bufferingLogic.getStartSegmentNumber(rep) == 11);
 
         delete m3u;


=====================================
modules/demux/avi/avi.c
=====================================
@@ -2277,8 +2277,10 @@ static int AVI_PacketNext( demux_t *p_demux )
         i_skip = __EVEN( avi_ck.i_size ) + 8;
     }
 
-    if( i_skip > SSIZE_MAX )
+#if SSIZE_MAX < UINT32_MAX // otherwise i_skip can't be bigger than SSIZE_MAX
+    if (i_skip > SSIZE_MAX)
         return VLC_EGENERIC;
+#endif
 
     if( vlc_stream_Read( p_demux->s, NULL, i_skip ) != i_skip )
     {


=====================================
modules/demux/dash/mpd/IsoffMainParser.cpp
=====================================
@@ -70,7 +70,7 @@ static void parseAvailability(MPD *mpd, Node *node, T *s)
     if(node->hasAttribute("availabilityTimeOffset"))
     {
         double val = Integer<double>(node->getAttributeValue("availabilityTimeOffset"));
-        s->addAttribute(new AvailabilityTimeOffsetAttr(val * CLOCK_FREQ));
+        s->addAttribute(new AvailabilityTimeOffsetAttr(vlc_tick_from_sec(val)));
     }
     if(node->hasAttribute("availabilityTimeComplete"))
     {


=====================================
modules/demux/hls/playlist/Parser.cpp
=====================================
@@ -790,9 +790,9 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::
         if(xstartTag->getAttributeByName("TIME-OFFSET"))
         {
             float offset = xstartTag->getAttributeByName("TIME-OFFSET")->floatingPoint();
-            if(offset > 0 && (offset * CLOCK_FREQ) <= playlist->duration.Get())
+            if(offset > 0 && vlc_tick_from_sec(offset) <= playlist->duration.Get())
                 playlist->presentationStartOffset.Set(CLOCK_FREQ * offset);
-            else if(offset < 0 && (-offset * CLOCK_FREQ) <= playlist->duration.Get())
+            else if(offset < 0 && vlc_tick_from_sec(-offset) <= playlist->duration.Get())
                 playlist->presentationStartOffset.Set(playlist->duration.Get() +
                                                       CLOCK_FREQ * offset);
         }


=====================================
modules/video_chroma/d3d11_fmt.c
=====================================
@@ -434,7 +434,7 @@ static HRESULT CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
                             bool hw_decoding, d3d11_device_t *out)
 {
 #ifndef VLC_WINSTORE_APP
-# define D3D11CreateDevice(args...)             pf_CreateDevice(args)
+# define D3D11CreateDevice(a,b,c,d,e,f,g,h,i,j)   pf_CreateDevice(a,b,c,d,e,f,g,h,i,j)
     /* */
     PFN_D3D11_CREATE_DEVICE pf_CreateDevice;
     pf_CreateDevice = (void *)GetProcAddress(hd3d->hdll, "D3D11CreateDevice");


=====================================
modules/video_output/Makefile.am
=====================================
@@ -214,6 +214,7 @@ libglwin32_plugin_la_SOURCES = $(OPENGL_VOUT_COMMONSOURCES) \
 	video_output/win32/events.c video_output/win32/events.h \
 	video_output/win32/sensors.cpp \
 	video_output/win32/win32touch.c video_output/win32/win32touch.h
+libglwin32_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
 libwgl_plugin_la_SOURCES = video_output/win32/wgl.c
 
 libglwin32_plugin_la_LIBADD = libchroma_copy.la -lopengl32 -lgdi32 $(LIBCOM) -luuid libvlc_opengl.la


=====================================
modules/video_output/win32/sensors.cpp
=====================================
@@ -157,7 +157,7 @@ void *HookWindowsSensors(vout_display_t *vd, HWND hwnd)
     ComPtr<ISensorManager> pSensorManager;
     HRESULT hr = CoCreateInstance( CLSID_SensorManager,
                       NULL, CLSCTX_INPROC_SERVER,
-                      IID_ISensorManager, (void**)&pSensorManager );
+                      IID_PPV_ARGS(pSensorManager.GetAddressOf()) );
     if (FAILED(hr))
         return NULL;
 


=====================================
src/text/url.c
=====================================
@@ -189,9 +189,9 @@ char *vlc_path2uri (const char *path, const char *scheme)
                       path[0]) == -1)
             buf = NULL;
         path += 2;
-# warning Drive letter-relative path not implemented!
         if (path[0] != DIR_SEP_CHAR)
         {
+            // Warning: Drive letter-relative path not implemented!
             errno = ENOTSUP;
             return NULL;
         }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a242c29b2445899584ae09abdba7a55dac7d603...1e98c09c3486f73538e35c856697e3699f9c68d4

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


VideoLAN code repository instance


More information about the vlc-commits mailing list