Commit 2880f080 authored by Michael Natterer's avatar Michael Natterer 😴

plug-ins: fix some new strncpy() warnings

parent 582c6920
......@@ -841,7 +841,8 @@ dicom_add_element (GSList *elements,
element->group_word = group_word;
element->element_word = element_word;
strncpy (element->value_rep, value_rep, sizeof (element->value_rep));
strncpy (element->value_rep, value_rep, sizeof (element->value_rep) - 1);
element->value_rep[sizeof (element->value_rep) - 1] = '\0';
element->element_length = element_length;
element->value = value;
......@@ -1062,7 +1063,8 @@ dicom_get_elements_list (gint32 image_ID)
guint16 element_word = 0;
/* sacrificial buffer */
strncpy (buf, parasites[i], sizeof (buf));
strncpy (buf, parasites[i], sizeof (buf) - 1);
buf[sizeof (buf) - 1] = '\0';
/* buf should now hold a string of the form
* dcm/XXXX-XXXX-AA where XXXX are Hex values for
......@@ -1105,7 +1107,10 @@ dicom_get_elements_list (gint32 image_ID)
/* and lastly, the VR */
if (ptr1)
strncpy (value_rep, ptr1, sizeof (value_rep));
{
strncpy (value_rep, ptr1, sizeof (value_rep) - 1);
value_rep[sizeof (value_rep) - 1] = '\0';
}
/*
* If all went according to plan, we should be able
......
......@@ -3581,7 +3581,7 @@ load_dialog (const gchar *filename)
range = gimp_page_selector_get_selected_range (GIMP_PAGE_SELECTOR (selector));
}
strncpy (plvals.pages, range, sizeof (plvals.pages));
strncpy (plvals.pages, range, sizeof (plvals.pages) - 1);
plvals.pages[strlen (range)] = '\0';
ps_pagemode = gimp_page_selector_get_target (GIMP_PAGE_SELECTOR (selector));
......@@ -3592,8 +3592,7 @@ load_dialog (const gchar *filename)
}
else
{
strncpy (plvals.pages, "1", 1);
plvals.pages[1] = '\0';
strncpy (plvals.pages, "1", sizeof (plvals.pages) - 1);
ps_pagemode = GIMP_PAGE_SELECTOR_TARGET_IMAGES;
}
......
......@@ -458,8 +458,8 @@ load_image (const gchar *filename,
for (i = 0; i < sgip->zsize; i ++)
if (sgiGetRow (sgip, rows[i], sgip->ysize - 1 - y, i) < 0)
g_printf ("sgiGetRow(sgip, rows[i], %d, %d) failed!\n",
sgip->ysize - 1 - y, i);
g_printerr ("sgiGetRow(sgip, rows[i], %d, %d) failed!\n",
sgip->ysize - 1 - y, i);
if (sgip->bpp == 1)
{
......
......@@ -4986,6 +4986,7 @@ gradient_cache_lookup (const gchar *name,
gradient_cache_zorch();
ci = g_new (GradientCacheItem, 1);
strncpy (ci->name, name, GRADIENT_NAME_MAX - 1);
ci->name[GRADIENT_NAME_MAX - 1] = '\0';
ci->next = gradient_cache_head;
ci->prev = NULL;
if (gradient_cache_head)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment