From: Karel Zak Date: Wed, 5 Oct 2016 09:11:45 +0000 (+0200) Subject: rtcwake: make sure buffer is zero terminated [coverity scan] X-Git-Tag: v2.29-rc2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a325f3c2066f5790e3a611157deffa74d975f8df;p=thirdparty%2Futil-linux.git rtcwake: make sure buffer is zero terminated [coverity scan] --- diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index f4e630a337..11f75ae9b0 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -250,7 +250,7 @@ static char **get_sys_power_states(struct rtcwake_control *ctl) fd = open(SYS_POWER_STATE_PATH, O_RDONLY); if (fd < 0) goto nothing; - if (read(fd, &buf, sizeof buf) <= 0) + if (read(fd, &buf, sizeof(buf) - 1) <= 0) goto nothing; ctl->possible_modes = strv_split(buf, " \n"); close(fd);