re PR libgomp/83106 (libgomp/target.c:2671:2: error: ‘strncat’ specified bound 5 equals source length [-Werror=stringop-overflow=])

PR libgomp/83106
	* target.c (gomp_target_init): Compute lengths just once and
	use them in both malloc size and subsequent copying.

From-SVN: r255080
This commit is contained in:
Jakub Jelinek 2017-11-22 21:49:56 +01:00 committed by Jakub Jelinek
parent 217e4393f7
commit b13547d821
2 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2017-11-22 Jakub Jelinek <jakub@redhat.com>
PR libgomp/83106
* target.c (gomp_target_init): Compute lengths just once and
use them in both malloc size and subsequent copying.
2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
* configure.ac: Set CET_FLAGS, update XCFLAGS and FCFLAGS.

View File

@ -2656,20 +2656,24 @@ gomp_target_init (void)
do
{
struct gomp_device_descr current_device;
size_t prefix_len, suffix_len, cur_len;
next = strchr (cur, ',');
plugin_name = (char *) malloc (1 + (next ? next - cur : strlen (cur))
+ strlen (prefix) + strlen (suffix));
prefix_len = strlen (prefix);
cur_len = next ? next - cur : strlen (cur);
suffix_len = strlen (suffix);
plugin_name = (char *) malloc (prefix_len + cur_len + suffix_len + 1);
if (!plugin_name)
{
num_devices = 0;
break;
}
strcpy (plugin_name, prefix);
strncat (plugin_name, cur, next ? next - cur : strlen (cur));
strcat (plugin_name, suffix);
memcpy (plugin_name, prefix, prefix_len);
memcpy (plugin_name + prefix_len, cur, cur_len);
memcpy (plugin_name + prefix_len + cur_len, suffix, suffix_len + 1);
if (gomp_load_plugin_for_device (&current_device, plugin_name))
{