[FFmpeg-devel] [PATCH] avformat/rtmpcrypt: fix discarded const warning

Michael Niedermayer michaelni at gmx.at
Fri Sep 18 23:02:17 CEST 2015

On Fri, Sep 18, 2015 at 09:50:29PM +0200, Nicolas George wrote:
> Le jour du Génie, an CCXXIII, Ganesh Ajjanagadde a écrit :
> > This patch silences a -Wdiscarded-qualifiers observed with GCC 5.2.
> > 
> > Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> > ---
> >  libavformat/rtmpcrypt.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> I am not sure this is correct: the buffer is const for a reason, the warning
> is right. An application would be completely allowed to give a buffer in
> read-only memory, or to reuse the contents of the buffer afterwards.
> Actually, I suspect this muxer, if used as first output in the tee muxer,
> would cause the next outputs to be corrupt.

IIRC the code is safe, just ugly
the writing only occurs if handshaked is set, which is only set
by ff_rtmpe_update_keystream() which is not part of the public
interface and only called from libavformat/rtmpproto.c
i assume but did not double check that libavformat/rtmpproto.c
calls the functions so that writable buffers are used

> The correct fix would probably be to allocate a new buffer, probably keeping
> it in the context for performances reasons instead of allocating each time.

id need to double check but i think the calling code possibly uses
the written buffer with the expectation that it has been updated

if that is so then such fix would break it.


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150918/054afb45/attachment.sig>

More information about the ffmpeg-devel mailing list