[FFmpeg-devel] [PATCH 3/3] ffmdec: change type of len to ptrdiff_t

Nicolas George george at nsup.org
Sat Jan 2 16:59:16 CET 2016


Le tridi 13 nivôse, an CCXXIV, Andreas Cadhalpun a écrit :
> It is used to store the difference between pointers, so ptrdiff_t is the
> correct type.
> 
> This prevents potential overflows.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  libavformat/ffmdec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
> index 3162354..f4f8144 100644
> --- a/libavformat/ffmdec.c
> +++ b/libavformat/ffmdec.c
> @@ -36,7 +36,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
>  {
>      FFMContext *ffm = s->priv_data;
>      int64_t pos, avail_size;
> -    int len;
> +    ptrdiff_t len;
>  
>      len = ffm->packet_end - ffm->packet_ptr;
>      if (size <= len)
> @@ -87,7 +87,8 @@ static int ffm_read_data(AVFormatContext *s,
>  {
>      FFMContext *ffm = s->priv_data;
>      AVIOContext *pb = s->pb;
> -    int len, fill_size, size1, frame_offset, id;
> +    int fill_size, size1, frame_offset, id;
> +    ptrdiff_t len;
>      int64_t last_pos = -1;
>  
>      size1 = size;

Should not be needed: the only place where packet_end becomes different from
packet_ptr is this:

	ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);

and ffm->packet_size is int (OTOH, this particular bit of pointer arithmetic
should probably check packet_size beforehand).

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160102/4b33d2c4/attachment.sig>


More information about the ffmpeg-devel mailing list