[vlc-devel] [PATCH 1/2] mosaic_bridge: fix format-overflow warning

Alexandre Janniaux ajanni at videolabs.io
Thu Sep 5 19:46:56 CEST 2019


Hi,

To be honest, I don't see either, but that's the name of the warning output by
GCC for this:

```
In file included from ../../include/vlc_common.h:1191,
                 from ../../modules/stream_out/mosaic_bridge.c:32:
../../modules/stream_out/mosaic_bridge.c: In function ‘Add’:
../../include/vlc_messages.h:97:5: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
   97 |     vlc_object_Log(VLC_OBJECT(o), p, vlc_module_name, __FILE__, __LINE__, \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |                    __func__, __VA_ARGS__)
      |                    ~~~~~~~~~~~~~~~~~~~~~~
../../include/vlc_messages.h:106:5: note: in expansion of macro ‘msg_Generic’
  106 |     msg_Generic(p_this, VLC_MSG_DBG, __VA_ARGS__)
      |     ^~~~~~~~~~~
../../modules/stream_out/mosaic_bridge.c:389:5: note: in expansion of macro ‘msg_Dbg’
  389 |     msg_Dbg( p_stream, "psz_chain: %s", psz_chain );
      |     ^~~~~~~
../../modules/stream_out/mosaic_bridge.c:389:36: note: format string is defined here
  389 |     msg_Dbg( p_stream, "psz_chain: %s", psz_chain );
      |                                    ^~
In file included from ../../include/vlc_common.h:1191,
                 from ../../modules/stream_out/mosaic_bridge.c:32:
../../modules/stream_out/mosaic_bridge.c: In function ‘video_update_format_decoder’:
../../include/vlc_messages.h:97:5: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
   97 |     vlc_object_Log(VLC_OBJECT(o), p, vlc_module_name, __FILE__, __LINE__, \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |                    __func__, __VA_ARGS__)
      |                    ~~~~~~~~~~~~~~~~~~~~~~
../../include/vlc_messages.h:106:5: note: in expansion of macro ‘msg_Generic’
  106 |     msg_Generic(p_this, VLC_MSG_DBG, __VA_ARGS__)
      |     ^~~~~~~~~~~
../../modules/stream_out/mosaic_bridge.c:584:9: note: in expansion of macro ‘msg_Dbg’
  584 |         msg_Dbg( p_owner->p_stream, "update filter: %s", psz_chain );
      |         ^~~~~~~
../../modules/stream_out/mosaic_bridge.c:584:53: note: format string is defined here
  584 |         msg_Dbg( p_owner->p_stream, "update filter: %s", psz_chain );
      |                                                     ^~
```

On Thu, Sep 05, 2019 at 05:34:58PM +0300, Rémi Denis-Courmont wrote:
> Hi,
>
> While passing NULL for %s is unequivocally UB, I don't see how this patch fixes any format overflow, TBH.
>
>
>
> Le 5 septembre 2019 14:37:24 GMT+03:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
> >---
> > modules/stream_out/mosaic_bridge.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> >diff --git a/modules/stream_out/mosaic_bridge.c
> >b/modules/stream_out/mosaic_bridge.c
> >index fa5d00c259..71c33090ef 100644
> >--- a/modules/stream_out/mosaic_bridge.c
> >+++ b/modules/stream_out/mosaic_bridge.c
> >@@ -386,7 +386,7 @@ static void *Add( sout_stream_t *p_stream, const
> >es_format_t *p_fmt )
> >     };
> >
> >   psz_chain = var_GetNonEmptyString( p_stream, CFG_PREFIX "vfilter" );
> >-    msg_Dbg( p_stream, "psz_chain: %s", psz_chain );
> >+    msg_Dbg( p_stream, "psz_chain: '%s'", psz_chain ? psz_chain : "");
> >     if( psz_chain )
> >     {
> >         filter_owner_t owner = {
> >@@ -581,7 +581,8 @@ inline static int video_update_format_decoder(
> >decoder_t *p_dec )
> >     {
> >         // update the filter after the format changed/is known
> >char *psz_chain = var_GetNonEmptyString( p_owner->p_stream, CFG_PREFIX
> >"vfilter" );
> >-        msg_Dbg( p_owner->p_stream, "update filter: %s", psz_chain );
> >+        msg_Dbg( p_owner->p_stream, "update filter: '%s'",
> >+                 psz_chain ?  psz_chain : "" );
> >         if( psz_chain )
> >         {
> >             es_format_t fmt;
> >--
> >2.23.0
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list