Alex Converse <alex.conve...@gmail.com> writes:

> On Fri, Sep 7, 2012 at 2:55 PM, Måns Rullgård <m...@mansr.com> wrote:
>> Alex Converse <alex.conve...@gmail.com> writes:
>>
>>> On Fri, Sep 7, 2012 at 2:45 PM, Måns Rullgård <m...@mansr.com> wrote:
>>>> Alex Converse <alex.conve...@gmail.com> writes:
>>>>
>>>>> Avoid writing the trailing NUL byte for id3v1 tags if length reaches max 
>>>>> length.
>>>>>
>>>>> Based on an idea by: Michael Niedermayer <michae...@gmx.at>
>>>>> ---
>>>>>  libavformat/mp3enc.c |    6 ++++--
>>>>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
>>>>> index fac39d9..4bd2eed 100644
>>>>> --- a/libavformat/mp3enc.c
>>>>> +++ b/libavformat/mp3enc.c
>>>>> @@ -37,8 +37,10 @@ static int id3v1_set_string(AVFormatContext *s, const 
>>>>> char *key,
>>>>>                              uint8_t *buf, int buf_size)
>>>>>  {
>>>>>      AVDictionaryEntry *tag;
>>>>> -    if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
>>>>> -        av_strlcpy(buf, tag->value, buf_size);
>>>>> +    if ((tag = av_dict_get(s->metadata, key, NULL, 0))) {
>>>>> +        buf_size = FFMIN(buf_size, strlen(tag->value));
>>>>> +        memcpy(buf, tag->value, buf_size);
>>>>> +    }
>>>>>      return !!tag;
>>>>>  }
>>>>>
>>>>> --
>>>>
>>>> Or even simpler, use strncpy() and drop the initial memset().
>>>>
>>>
>>> That won't compile,
>>
>> Why not?
>>
>
> error: implicit declaration of function
> ‘strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy’

So drop that nonsense.  There is nothing more ridiculous than elaborate
workarounds for self-imposed rules.

-- 
Måns Rullgård
m...@mansr.com
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to