From: Zbigniew Jędrzejewski-Szmek Date: Sun, 19 Feb 2017 18:43:22 +0000 (-0500) Subject: logind: check return value from lseek X-Git-Tag: v233.3~52 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=f69009b9ced2d38cf8a067c23c77b7bf000afb63 logind: check return value from lseek In practice this doesn't matter much because the read that follows will likely fail, but we'll get a better error message. CID #1368233. --- diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 01b9ec17b..84a46bf7b 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -383,7 +383,8 @@ int seat_read_active_vt(Seat *s) { if (!seat_has_vts(s)) return 0; - lseek(s->manager->console_active_fd, SEEK_SET, 0); + if (lseek(s->manager->console_active_fd, SEEK_SET, 0) < 0) + return log_error_errno(errno, "lseek on console_active_fd failed: %m"); k = read(s->manager->console_active_fd, t, sizeof(t)-1); if (k <= 0) { @@ -400,10 +401,8 @@ int seat_read_active_vt(Seat *s) { } r = safe_atou(t+3, &vtnr); - if (r < 0) { - log_error("Failed to parse VT number %s", t+3); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to parse VT number \"%s\": %m", t+3); if (!vtnr) { log_error("VT number invalid: %s", t+3);