]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rtcwake: make sure buffer is zero terminated [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 5 Oct 2016 09:11:45 +0000 (11:11 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 5 Oct 2016 09:11:45 +0000 (11:11 +0200)
sys-utils/rtcwake.c

index f4e630a33794dae934ddd4550a664f25c4e0d8ed..11f75ae9b084a6b2790ed6706dfafd1597de0e95 100644 (file)
@@ -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);