]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: use memdup_suffix0() where appropiate
authorLennart Poettering <lennart@poettering.net>
Wed, 2 Jul 2025 14:25:00 +0000 (16:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 2 Jul 2025 14:25:06 +0000 (16:25 +0200)
memdup_suffix0() is the call of choice when we are dealing with an input
that might not be NUL terminated. strndup() assumes NUL termination.

src/login/logind-utmp.c

index 8305ae743fa83f0ab578c1a02e55ce887d6b91cc..8f6914f7250cbc7628315be1b06827bed237dcde 100644 (file)
@@ -43,7 +43,7 @@ int manager_read_utmp(Manager *m) {
                 if (!pid_is_valid(u->ut_pid))
                         continue;
 
-                t = strndup(u->ut_line, sizeof(u->ut_line));
+                t = memdup_suffix0(u->ut_line, sizeof(u->ut_line));
                 if (!t)
                         return log_oom();