summaryrefslogtreecommitdiff
path: root/daemon/gdm-session-record.c
diff options
context:
space:
mode:
authorRobert Mader <robert.mader@posteo.de>2019-03-31 15:50:38 +0200
committerRay Strode <halfline@gmail.com>2019-08-13 20:27:10 +0000
commit11a4eede592cfef5b953f21fe69435af7598de71 (patch)
tree09c3fe926c75c43ca42443478ba91e45cad0702d /daemon/gdm-session-record.c
parenta5f06d7f960b7289c2bdaad45fdcebdb2319ff5e (diff)
downloadgdm-11a4eede592cfef5b953f21fe69435af7598de71.tar.gz
gdm-session-record: Use memccpy() instead of strncpy()
...to silence build warnings. Suggested by Ray Strode
Diffstat (limited to 'daemon/gdm-session-record.c')
-rw-r--r--daemon/gdm-session-record.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/daemon/gdm-session-record.c b/daemon/gdm-session-record.c
index d2df5887..7719d0a8 100644
--- a/daemon/gdm-session-record.c
+++ b/daemon/gdm-session-record.c
@@ -64,16 +64,12 @@ record_set_username (UTMP *u,
const char *username)
{
#if defined(HAVE_UT_UT_USER)
- strncpy (u->ut_user,
- username,
- sizeof (u->ut_user));
+ memccpy (u->ut_user, username, '\0', sizeof (u->ut_user));
g_debug ("using ut_user %.*s",
(int) sizeof (u->ut_user),
u->ut_user);
#elif defined(HAVE_UT_UT_NAME)
- strncpy (u->ut_name,
- username,
- sizeof (u->ut_name));
+ memccpy (u->ut_name, username, '\0', sizeof (u->ut_name));
g_debug ("using ut_name %.*s",
(int) sizeof (u->ut_name),
u->ut_name);
@@ -136,7 +132,7 @@ record_set_host (UTMP *u,
}
if (hostname != NULL) {
- strncpy (u->ut_host, hostname, sizeof (u->ut_host));
+ memccpy (u->ut_host, hostname, '\0', sizeof (u->ut_host));
g_debug ("using ut_host %.*s", (int) sizeof (u->ut_host), u->ut_host);
#ifdef HAVE_UT_UT_SYSLEN
u->ut_syslen = MIN (strlen (hostname), sizeof (u->ut_host));
@@ -158,12 +154,14 @@ record_set_line (UTMP *u,
*/
if (display_device != NULL
&& g_str_has_prefix (display_device, "/dev/")) {
- strncpy (u->ut_line,
+ memccpy (u->ut_line,
display_device + strlen ("/dev/"),
+ '\0',
sizeof (u->ut_line));
} else if (x11_display_name != NULL) {
- strncpy (u->ut_line,
+ memccpy (u->ut_line,
x11_display_name,
+ '\0',
sizeof (u->ut_line));
}