[FFmpeg-devel] lavu/opt: add escaping to av_opt_serialize

Lukasz Marek lukasz.m.luki2 at gmail.com
Thu Nov 27 19:53:12 CET 2014


On 27 November 2014 at 15:05, Stefano Sabatini <stefasab at gmail.com> wrote:

> On date Tuesday 2014-11-25 20:38:59 +0100, Lukasz Marek encoded:
> > Patch attached.
>
> > From 2a9de161df4e1d0083264dde94ec5b8af59cec35 Mon Sep 17 00:00:00 2001
> > From: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> > Date: Tue, 25 Nov 2014 20:25:10 +0100
> > Subject: [PATCH] lavu/opt: add escaping to av_opt_serialize
> >
> > Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> > ---
> >  libavutil/opt.c    | 12 +++++++++++-
> >  libavutil/opt.h    |  1 +
> >  tests/ref/fate/opt |  7 +++++--
> >  3 files changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index 0546a37..5b9cc35 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -1843,6 +1843,11 @@ int av_opt_serialize(void *obj, int opt_flags,
> int flags, char **buffer,
> >      uint8_t *buf;
> >      AVBPrint bprint;
> >      int ret, cnt = 0;
> > +    const char special_chars[] = {pairs_sep, key_val_sep, '\0'};
> > +
> > +    if (pairs_sep == '\0' || key_val_sep == '\0' || pairs_sep ==
> key_val_sep ||
> > +        pairs_sep == '\\' || key_val_sep == '\\')
> > +        return AVERROR(EINVAL);
>
> maybe send a log here
>

Added.


> > --- a/libavutil/opt.h
> > +++ b/libavutil/opt.h
> > @@ -887,6 +887,7 @@ int av_opt_is_set_to_default_by_name(void *obj,
> const char *name, int search_fla
> >   * @param[in]  key_val_sep   character used to separate key from value
> >   * @param[in]  pairs_sep     character used to separate two pairs from
> each other
> >   * @return                   >= 0 on success, negative on error
> > + * @warning Separators cannot be neither '\\' nor '\0'. They also
> cannot be the same.
> >   */
>
> You could mention escaping in the docs, for example:
>
> A key/value or pairs separator occurring in the serialized value or
> name string are escaped through the av_escape() function.
>

Added.
Updated patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavu-opt-add-escaping-to-av_opt_serialize.patch
Type: text/x-patch
Size: 6438 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141127/c140c40c/attachment.bin>


More information about the ffmpeg-devel mailing list