Skip to content

Commit

Permalink
Merge pull request #5567 from radarhere/sprintf
Browse files Browse the repository at this point in the history
Limit sprintf modes to 10 characters
  • Loading branch information
radarhere committed Jul 1, 2021
2 parents 23b2151 + 518ee37 commit 31c4738
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/libImaging/Convert.c
Expand Up @@ -1594,9 +1594,8 @@ convert(
#ifdef notdef
return (Imaging)ImagingError_ValueError("conversion not supported");
#else
static char buf[256];
/* FIXME: may overflow if mode is too large */
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
static char buf[100];
snprintf(buf, 100, "conversion from %.10s to %.10s not supported", imIn->mode, mode);
return (Imaging)ImagingError_ValueError(buf);
#endif
}
Expand Down Expand Up @@ -1645,11 +1644,11 @@ ImagingConvertTransparent(Imaging imIn, const char *mode, int r, int g, int b) {
}
#else
{
static char buf[256];
/* FIXME: may overflow if mode is too large */
sprintf(
static char buf[100];
snprintf(
buf,
"conversion from %s to %s not supported in convert_transparent",
100,
"conversion from %.10s to %.10s not supported in convert_transparent",
imIn->mode,
mode);
return (Imaging)ImagingError_ValueError(buf);
Expand Down

0 comments on commit 31c4738

Please sign in to comment.