app, libgimp*, plug-ins: Use strncpy_s on Windows to fix CRT_INSECURE_DEPRECATE

This commit is contained in:
Bruno Lopes 2026-03-31 12:05:31 -03:00
parent fe185577e2
commit ed3611efa6
5 changed files with 39 additions and 1 deletions

View file

@ -644,7 +644,11 @@ utf8_copy_sized (char *dest,
if (size == 0)
return;
#ifndef _UCRT
strncpy (dest, src, size);
#else
strncpy_s (dest, sizeof (dest), src, size);
#endif
if (dest[size - 1] != 0)
{

View file

@ -864,7 +864,11 @@ gimp_thumb_png_name (const gchar *uri)
name[i * 2 + 1] = (n > 9) ? 'a' + n - 10 : '0' + n;
}
#ifndef _UCRT
strncpy (name + 32, ".png", 5);
#else
strncpy_s (name + 32, 8, ".png", 5);
#endif
return (const gchar *) name;
}

View file

@ -454,7 +454,12 @@ gimp_eevl_quantity (GimpEevl *eva)
identifier = g_newa (gchar, consumed_token.value.size + 1);
#ifndef _UCRT
strncpy (identifier, consumed_token.value.c, consumed_token.value.size);
#else
strncpy_s (identifier, consumed_token.value.size + 1,
consumed_token.value.c, consumed_token.value.size);
#endif
identifier[consumed_token.value.size] = '\0';
if (eva->options.unit_resolver_proc (identifier,

View file

@ -1925,7 +1925,12 @@ export_image (GFile *file,
if (save_comment && comment && strlen (comment))
{
parameters.cp_comment = g_malloc0 (strlen (comment) + 1);
#ifndef _UCRT
strncpy (parameters.cp_comment, comment, strlen (comment));
#else
strncpy_s (parameters.cp_comment, sizeof (parameters.cp_comment),
comment, strlen (comment));
#endif
}
if (! cmyk)

View file

@ -83,14 +83,22 @@ resource_load (FILE *file)
gchar type[5];
guint32 size;
#ifndef _UCRT
strncpy (type, header.type, 4);
#else
strncpy_s (type, 5, header.type, 4);
#endif
type[4] = '\0';
size = GUINT32_FROM_BE (header.size);
if (! strncmp (header.type, "icns", 4) && size > sizeof (IcnsResourceHeader))
{
res = (IcnsResource *) g_new (guchar, sizeof (IcnsResource) + size);
#ifndef _UCRT
strncpy (res->type, header.type, 4);
#else
strncpy_s (res->type, 5, header.type, 4);
#endif
res->type[4] = '\0';
res->size = size;
res->cursor = sizeof (IcnsResourceHeader);
@ -144,7 +152,11 @@ resource_get_next (IcnsResource *icns,
return FALSE;
header = (IcnsResourceHeader *) &(icns->data[icns->cursor]);
#ifndef _UCRT
strncpy (res->type, header->type, 4);
#else
strncpy_s (res->type, 5, header->type, 4);
#endif
res->size = GUINT32_FROM_BE (header->size);
res->cursor = sizeof (IcnsResourceHeader);
res->data = &(icns->data[icns->cursor]);
@ -455,7 +467,11 @@ icns_attach_image (GimpImage *image,
guint expected_size;
gboolean layer_loaded = FALSE;
#ifndef _UCRT
strncpy (layer_name, icontype->type, 4);
#else
strncpy_s (layer_name, 5, icontype->type, 4);
#endif
layer_name[4] = '\0';
row = 4 * icontype->width;
@ -481,7 +497,11 @@ icns_attach_image (GimpImage *image,
gchar *temp_file_type = NULL;
gchar *procedure_name = NULL;
#ifndef _UCRT
strncpy (image_type, (gchar *) icns->data + 8, 4);
#else
strncpy_s (image_type, 5, (gchar *) icns->data + 8, 4);
#endif
image_type[4] = '\0';
/* PNG */