diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-05-27 10:16:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-27 10:59:21 +0300 |
commit | 41f2ea4045b183b7e2d0c5f61d7ab7958267122e (patch) | |
tree | 044d173db6e928798c27a2c014497869e9594f11 /source/blender/imbuf/intern | |
parent | 1276d0024fb66825ec219ba742187cfcf338cbd2 (diff) |
Fix incorrect BLI_snprintf usage
Event though in practice this wasn't causing problems as the fixed size
buffers are generally large enough not to truncate text.
Using the result from `snprint` or `BLI_snprintf` to step over a fixed
size buffer allows for buffer overruns as the returned value is the size
needed to copy the entire string, not the number of bytes copied.
Building strings using this convention with multiple calls:
ofs += BLI_snprintf(str + ofs, str_len_max - ofs);
.. caused the size argument to become negative,
wrapping it to a large value when cast to the unsigned argument.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 440375f60dc..48b5b0c34db 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -516,7 +516,8 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) * The first "Blender" is a simple identify to help * in the read process. */ - text_len = BLI_snprintf(text, text_size, "Blender:%s:%s", prop->name, IDP_String(prop)); + text_len = BLI_snprintf_rlen( + text, text_size, "Blender:%s:%s", prop->name, IDP_String(prop)); jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *)text, text_len + 1); /* TODO(sergey): Ideally we will try to re-use allocation as |