On Wed, 2015-03-04 at 12:31 -0800, Mark Reid wrote:
> +/*
> + * Returns the calculated length a local tag containing an utf-8 string as 
> utf-16
> + */
> +static int mxf_utf16_local_tag_length(const char *utf8_str)
> +{
> +    uint64_t size;
> +
> +    if (!utf8_str)
> +        return 0;
> +
> +    size = mxf_utf16len(utf8_str);
> +    if (size >= UINT16_MAX || size * 2 >= UINT16_MAX) {

if (size >= UINT16_MAX/2) {

> +        av_log(NULL, AV_LOG_ERROR, "utf16 local tag size %"PRIx64" invalid 
> (too large), ignoring\n", size);
> +        return 0;
> +    }
> +
> +    return 4 + size * 2;
> +}
> +
> +/*
> + * Write a local tag containing an utf-8 string as utf-16
>   */
>  static void mxf_write_local_tag_utf16(AVIOContext *pb, int tag, const char 
> *value)
>  {
> -    int i, size = strlen(value);
> +    uint64_t size = mxf_utf16len(value);
> +
> +    if (size >= UINT16_MAX || size * 2 >= UINT16_MAX) {

if (size >= UINT16_MAX/2) {

> +        av_log(NULL, AV_LOG_ERROR, "utf16 local tag size %"PRIx64" invalid 
> (too large), ignoring\n", size);
> +        return;
> +    }
> +
>      mxf_write_local_tag(pb, size*2, tag);
> -    for (i = 0; i < size; i++)
> -        avio_wb16(pb, value[i]);
> +    avio_put_str16be(pb, value);
>  }

The rest looks OK to me. Nice work :)

/Tomas

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to