Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31c4738

Browse files
authored
Merge pull request #5567 from radarhere/sprintf
Limit sprintf modes to 10 characters
2 parents 23b2151 + 518ee37 commit 31c4738

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/libImaging/Convert.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,9 +1594,8 @@ convert(
15941594
#ifdef notdef
15951595
return (Imaging)ImagingError_ValueError("conversion not supported");
15961596
#else
1597-
static char buf[256];
1598-
/* FIXME: may overflow if mode is too large */
1599-
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
1597+
static char buf[100];
1598+
snprintf(buf, 100, "conversion from %.10s to %.10s not supported", imIn->mode, mode);
16001599
return (Imaging)ImagingError_ValueError(buf);
16011600
#endif
16021601
}
@@ -1645,11 +1644,11 @@ ImagingConvertTransparent(Imaging imIn, const char *mode, int r, int g, int b) {
16451644
}
16461645
#else
16471646
{
1648-
static char buf[256];
1649-
/* FIXME: may overflow if mode is too large */
1650-
sprintf(
1647+
static char buf[100];
1648+
snprintf(
16511649
buf,
1652-
"conversion from %s to %s not supported in convert_transparent",
1650+
100,
1651+
"conversion from %.10s to %.10s not supported in convert_transparent",
16531652
imIn->mode,
16541653
mode);
16551654
return (Imaging)ImagingError_ValueError(buf);

0 commit comments

Comments
 (0)