[FFmpeg-devel] [PATCH v2] avformat/hls: use av_strlcopy instead of strncpy

Leo Izen leo.izen at gmail.com
Mon Oct 30 16:01:13 EET 2023


On 10/30/23 09:55, Nicolas George wrote:
> Leo Izen (12023-10-30):
>>> difference: user data should not be silently truncated.
>> There isn't really a bug here, just an extraneous compiler warning.
> 
> Truncating user data silently is a bug. The warning is right and needs
> proper fix.
> 
> Regards,
> 

The warning is not that truncation might occur, but that if it does 
occur, the buffer won't be nul-terminated. This is not actually the case 
because the size passed to strncpy is one smaller than the buffer size, 
and the buffer is zeroed. However, the compiler doesn't know this.

Also, fwiw, info->assoc_language is the name of a language. It shouldn't 
actually ever be 63 characters long for real streams in the wild, and 
truncating it is just a memory-safety precaution. It's not a bug.

- Leo Izen


More information about the ffmpeg-devel mailing list