[FFmpeg-devel] [PATCH] libavcodec: Added Selftest for libavcodec/avpacket.c

Michael Niedermayer michael at niedermayer.cc
Mon Oct 17 18:24:19 EEST 2016


Hi

first, please dont forget to submit an application to outreachy theres
a deadline in a few hours


On Sun, Oct 16, 2016 at 04:28:23PM -0700, Thomas Turner wrote:
> Improved code coverage for libavcodec.
> Function(s) Tested: av_packet_clone().

It seems your mails get stuck in the moderation que
please make sure the address you use to send patches is subscribed
note, you can subscscribe multple addresses and set all but one to
nomail


[...]
> +static int IS_SPRINTF_ERR(int val, int tot_elem)
> +{
> +    int ret = 0;
> +    if(val > tot_elem){
> +        perror("overflow");
> +        ret = 1;
> +    }
> +    else if(val < 0){
> +        perror("sprintf");
> +        ret = 1;
> +    }
> +    if(ret > 0)
> +        return ret;
> +
> +    return ret;
> +}
> +
> +static void LOG_AVPACKET(AVPacket avpkt, const char* message)
> +{
> +    int val, tot_elem;
> +
> +    /* initialize array's */
> +    char buf_info[256]  = {0};
> +    char data_info[256] = {0};
> +    char side_info[256] = {0};
> +
> +    /* get buf information */
> +    if(avpkt.buf){
> +        val = sprintf(buf_info, "{buffer: %p,  data: %p, size: %d}",
> +            avpkt.buf->buffer, avpkt.buf->data, avpkt.buf->size);
> +        tot_elem = strlen(buf_info);
> +
> +        /** if sprintf error found */
> +        if(IS_SPRINTF_ERR(val, tot_elem))
> +            exit(-1);

iam not sure what this is doing  but you should just use snprintf()
instead of sprintf()
sprintf() is not "safe" as it doesnt check its output buffer size
its more a matter or principle, not that any specific case would
actually write over the array end

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- 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/20161017/a52caa1b/attachment.sig>


More information about the ffmpeg-devel mailing list