X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futmp-wtmp.c;h=8717dbac2d06161cba09989bdbc2102b6d4def5e;hp=046fb584fb08cb18506f89ffc1d0a68eca03f313;hb=268888765352e4dcf07e40917fef6ab41b7deba1;hpb=f274ece0f76b5709408821e317e87aef76123db6 diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index 046fb584f..8717dbac2 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -403,10 +403,12 @@ int utmp_wall(const char *message, bool (*match_tty)(const char *tty)) { 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; }