/*
* we have successfully found OUR instance,
* save the device GUID before exiting
- *
- * We can use GNUNET_strlcpy here because instance key is null-
- * terminated by RegEnumKeyExA.
*/
GNUNET_strlcpy (device_guid, instance_key, sizeof (device_guid));
retval = TRUE;
if (0 != hostname_size)
{
hostname = GNUNET_malloc (hostname_size + 1);
- /* intentionally use strncpy (hostname not null terminated) */
- (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1,
- hostname_size);
- hostname[hostname_size] = '\0';
+ GNUNET_strlcpy (hostname,
+ ((char *) &msg[1]) + trusted_ip_size + 1,
+ hostname_size + 1);
}
/* unset GNUNET_TESTING_PREFIX if present as it is more relevant for testbed */
evstr = getenv (GNUNET_TESTING_PREFIX);
if (0 != username_length)
{
username = GNUNET_malloc (username_length + 1);
- /* intentionally use strncpy (message payload is not null terminated) */
- strncpy (username, ptr, username_length);
+ GNUNET_strlcpy (username, ptr, username_length + 1);
ptr += username_length;
}
hostname = GNUNET_malloc (hostname_length + 1);
- /* intentionally use strncpy (message payload is not null terminated) */
- strncpy (hostname,
- ptr,
- hostname_length);
+ GNUNET_strlcpy (hostname, ptr, hostname_length + 1);
if (NULL == (host_cfg = GNUNET_TESTBED_extract_config_ (&msg->header)))
{
GNUNET_free_non_null (username);
{
size = pmatch[2].rm_eo - pmatch[2].rm_so;
username = GNUNET_malloc (size + 1);
- /*
- * Intentionally use strncpy (buf is not necessarily null-terminated)
- */
- username[size] = '\0';
- GNUNET_assert (NULL != strncpy (username, buf + pmatch[2].rm_so, size));
+ GNUNET_assert(0 != GNUNET_strlcpy (username,
+ buf + pmatch[2].rm_so,
+ size + 1));
}
if (-1 != pmatch[5].rm_so)
{
}
size = pmatch[3].rm_eo - pmatch[3].rm_so;
hostname = GNUNET_malloc (size + 1);
- /*
- * Intentionally use strncpy (buf is not necessarily null-terminated)
- */
- hostname[size] = '\0';
- GNUNET_assert (NULL != strncpy (hostname, buf + pmatch[3].rm_so, size));
+ GNUNET_assert(0 != GNUNET_strlcpy (hostname,
+ buf + pmatch[3].rm_so,
+ size + 1));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Successfully read host %s, port %d and user %s from file\n",
(NULL == hostname) ? "NULL" : hostname,
/*
* we have successfully found OUR instance,
* save the device GUID before exiting
- *
- * We can use GNUNET_strlcpy here because instance key is null-
- * terminated by RegEnumKeyExA.
*/
GNUNET_strlcpy (device_guid, instance_key, sizeof (device_guid));
retval = TRUE;