app, plug-ins: More sscanf_s on Windows

This commit is contained in:
Bruno Lopes 2026-03-31 16:58:26 -03:00
parent 8aeb5d6f53
commit 3807b2f311
6 changed files with 60 additions and 3 deletions

View file

@ -135,6 +135,7 @@ gimp_gradient_load (GimpContext *context,
gint right_color_type;
gdouble left_rgba[4];
gdouble right_rgba[4];
gint n_matched;
seg = gimp_gradient_segment_new ();
@ -175,9 +176,16 @@ gimp_gradient_load (GimpContext *context,
gegl_color_set_pixel (seg->left_color, babl_format ("R'G'B'A double"), left_rgba);
gegl_color_set_pixel (seg->right_color, babl_format ("R'G'B'A double"), right_rgba);
switch (sscanf (end, "%d %d %d %d",
&type, &color,
&left_color_type, &right_color_type))
#ifndef _UCRT
n_matched = sscanf (end, "%d %d %d %d",
&type, &color,
&left_color_type, &right_color_type);
#else
n_matched = sscanf_s (end, "%d %d %d %d",
&type, &color,
&left_color_type, &right_color_type);
#endif
switch (n_matched)
{
case 4:
seg->left_color_type = (GimpGradientColor) left_color_type;

View file

@ -904,12 +904,21 @@ gimp_levels_config_load_cruft (GimpLevelsConfig *config,
return FALSE;
}
#ifndef _UCRT
fields = sscanf (line, "%d %d %d %d %31s",
&low_input[i],
&high_input[i],
&low_output[i],
&high_output[i],
float_buf);
#else
fields = sscanf_s (line, "%d %d %d %d %31s",
&low_input[i],
&high_input[i],
&low_output[i],
&high_output[i],
float_buf, (unsigned) sizeof (float_buf));
#endif
g_free (line);

View file

@ -620,6 +620,7 @@ compose_run (GimpProcedure *procedure,
parasite_data = (gchar *) gimp_parasite_get_data (parasite, &parasite_size);
parasite_data = g_strndup (parasite_data, parasite_size);
#ifndef _UCRT
nret = sscanf (parasite_data,
"source=%d type=%31s %d %d %d %d",
&source,
@ -628,6 +629,17 @@ compose_run (GimpProcedure *procedure,
input + 1,
input + 2,
input + 3);
#else
nret = sscanf_s (parasite_data,
"source=%d type=%31s %d %d %d %d",
&source,
composevals.compose_type,
(unsigned int) sizeof (composevals.compose_type),
input,
input + 1,
input + 2,
input + 3);
#endif
gimp_parasite_free (parasite);
g_free (parasite_data);

View file

@ -1659,7 +1659,11 @@ load_options (fractalexplorerOBJ *xxx,
while (!feof (fp) && strcmp (load_buf, "<EOF>"))
{
/* Get option name */
#ifndef _UCRT
sscanf (load_buf, "%255s %255s", str_buf, opt_buf);
#else
sscanf_s (load_buf, "%255s %255s", str_buf, (unsigned)_countof(str_buf), opt_buf, (unsigned)_countof(opt_buf));
#endif
if (!strcmp (str_buf, "fractaltype:"))
{

View file

@ -202,8 +202,16 @@ gfig_read_parameter_gimp_rgb (gchar **text,
ptr++;
if (!strcmp (tmpstr, name))
{
#ifndef _UCRT
sscanf (ptr, fmt_str,
colorstr_r, colorstr_g, colorstr_b, colorstr_a);
#else
sscanf_s (ptr, fmt_str,
colorstr_r, (unsigned int)sizeof(colorstr_r),
colorstr_g, (unsigned int)sizeof(colorstr_g),
colorstr_b, (unsigned int)sizeof(colorstr_b),
colorstr_a, (unsigned int)sizeof(colorstr_a));
#endif
gegl_color_set_rgba_with_space (*style_entry,
g_ascii_strtod (colorstr_r, &endptr),
g_ascii_strtod (colorstr_g, &endptr),
@ -237,7 +245,11 @@ gfig_load_style (Style *style,
get_line (load_buf2, MAX_LOAD_LINE, fp, 0);
/* nuke final > and preserve spaces in name */
#ifndef _UCRT
if (1 != sscanf (load_buf2, "<Style %99[^>]>", name))
#else
if (1 != sscanf_s (load_buf2, "<Style %99[^>]>", name, (unsigned int)sizeof(name)))
#endif
{
/* no style data, copy default style and fail silently */
gfig_style_copy (style, &gfig_context->default_style, "default style");

View file

@ -545,7 +545,11 @@ gfig_load (GimpGfig *gfig,
get_line (load_buf, MAX_LOAD_LINE, fp, 1);
#ifndef _UCRT
sscanf (load_buf, "%10s %10s %lf", magic1, magic2, &version);
#else
sscanf_s (load_buf, "%10s %10s %lf", magic1, (unsigned)_countof(magic1), magic2, (unsigned)_countof(magic2), &version);
#endif
if (strcmp (magic1, "GFIG") || strcmp (magic2, "Version"))
{
@ -557,7 +561,11 @@ gfig_load (GimpGfig *gfig,
}
get_line (load_buf, MAX_LOAD_LINE, fp, 0);
#ifndef _UCRT
sscanf (load_buf, "Name: %100s", str_buf);
#else
sscanf_s (load_buf, "Name: %100s", str_buf, (unsigned)_countof(str_buf));
#endif
gfig_name_decode (load_buf, str_buf);
gfig_obj->draw_name = g_strdup (load_buf);
@ -714,7 +722,11 @@ load_options (GFigObj *gfig,
printf ("option %s val %s\n", str_buf, opt_buf);
#else
#ifndef _UCRT
sscanf (load_buf, "%255s %255s", str_buf, opt_buf);
#else
sscanf_s (load_buf, "%255s %255s", str_buf, (unsigned)_countof(str_buf), opt_buf, (unsigned)_countof(opt_buf));
#endif
#endif /* DEBUG */
if (!strcmp (str_buf, "GridSpacing:"))