From b9771c5f5edcbeb965fa291a281943d866c3ddb6 Mon Sep 17 00:00:00 2001 From: lurchi Date: Thu, 27 Jun 2019 10:49:40 +0200 Subject: use GNUNET_strlcpy instead of strncpy where possible --- src/util/common_logging.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/util/common_logging.c') diff --git a/src/util/common_logging.c b/src/util/common_logging.c index b5678e5be..3193878b8 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -1082,11 +1082,11 @@ mylog (enum GNUNET_ErrorType kind, return; } flush_bulk (date); - strncpy (last_bulk, buf, sizeof (last_bulk)); + GNUNET_strlcpy (last_bulk, buf, sizeof (last_bulk)); last_bulk_repeat = 0; last_bulk_kind = kind; last_bulk_time = GNUNET_TIME_absolute_get (); - strncpy (last_bulk_comp, comp, COMP_TRACK_SIZE); + GNUNET_strlcpy (last_bulk_comp, comp, sizeof (last_bulk_comp)); output_message (kind, comp, date, buf); } } @@ -1364,9 +1364,8 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) if (NULL == pid) return "NULL"; ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); - strncpy (buf, ret, sizeof (buf) - 1); + GNUNET_strlcpy (buf, ret, sizeof (buf)); GNUNET_free (ret); - buf[4] = '\0'; return buf; } @@ -1390,9 +1389,8 @@ GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid) if (NULL == pid) return "NULL"; ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); - strncpy (buf, ret, sizeof (buf) - 1); + GNUNET_strlcpy (buf, ret, sizeof (buf)); GNUNET_free (ret); - buf[4] = '\0'; return buf; } -- cgit v1.2.3