systemd-199/src/shared/utmp-wtmp.c:228: buffer_size_warning: Calling
strncpy with a maximum size argument of 32 bytes on destination array
"store.ut_line" of size 32 bytes might leave the destination string
unterminated.
The destination string is unterminated on purpose, but we must
remember that.
if (u->ut_type != USER_PROCESS || u->ut_user[0] == 0)
continue;
+ /* this access is fine, because strlen("/dev/") << 32 (UT_LINESIZE) */
if (path_startswith(u->ut_line, "/dev/"))
path = u->ut_line;
else {
- if (asprintf(&buf, "/dev/%s", u->ut_line) < 0) {
+ if (asprintf(&buf, "/dev/%.*s",
+ sizeof(u->ut_line), u->ut_line) < 0) {
r = -ENOMEM;
goto finish;
}