[FFmpeg-devel] [PATCH] Fix sdp size check on fmtp integer parameters

Michael Niedermayer michael at niedermayer.cc
Wed Feb 27 17:14:34 EET 2019


On Mon, Feb 25, 2019 at 02:54:50PM +0100, Olivier Maignial wrote:
> ---
>  libavformat/rtpdec_mpeg4.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
> index 4f70599..f632ebf 100644
> --- a/libavformat/rtpdec_mpeg4.c
> +++ b/libavformat/rtpdec_mpeg4.c
> @@ -289,15 +289,15 @@ static int parse_fmtp(AVFormatContext *s,
>          for (i = 0; attr_names[i].str; ++i) {
>              if (!av_strcasecmp(attr, attr_names[i].str)) {
>                  if (attr_names[i].type == ATTR_NAME_TYPE_INT) {
> -                    int val = atoi(value);
> -                    if (val > 32) {
> +                    long int val = strtol(value, NULL, 10);
> +                    if (errno == ERANGE || val > INT_MAX || val < INT_MIN) {

i belive strtol can fail with other errno values


>                          av_log(s, AV_LOG_ERROR,
> -                               "The %s field size is invalid (%d)\n",
> +                               "The %s field size is invalid (%ld)\n",
>                                 attr, val);
>                          return AVERROR_INVALIDDATA;
>                      }

>                      *(int *)((char *)data+
> -                        attr_names[i].offset) = val;
> +                        attr_names[i].offset) = (int) val;

this is not needed, though it does no harm if the intend is to make it
clear that the type is converted intentionally here

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190227/7ad3fd42/attachment.sig>


More information about the ffmpeg-devel mailing list