summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2019-05-28 12:53:58 +0200
committerKarel Zak2019-05-28 12:53:58 +0200
commitd3149a855680d59f0703eb8d3af651c33aa19c37 (patch)
tree9a428aada3a929441a8fb45630851093cd92e0f1 /sys-utils
parentbuild-sys: add info about ASAN (diff)
downloadkernel-qcow2-util-linux-d3149a855680d59f0703eb8d3af651c33aa19c37.tar.gz
kernel-qcow2-util-linux-d3149a855680d59f0703eb8d3af651c33aa19c37.tar.xz
kernel-qcow2-util-linux-d3149a855680d59f0703eb8d3af651c33aa19c37.zip
rtcwake: terminate mode and excl[]
* terminate string read from /proc * terminate array for exclusive options Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/rtcwake.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 1058e8af9..4f854bb0b 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -247,12 +247,15 @@ static char **get_sys_power_states(struct rtcwake_control *ctl)
if (!ctl->possible_modes) {
char buf[256] = { 0 };
+ ssize_t ss;
fd = open(SYS_POWER_STATE_PATH, O_RDONLY);
if (fd < 0)
goto nothing;
- if (read(fd, &buf, sizeof(buf) - 1) <= 0)
+ ss = read(fd, &buf, sizeof(buf) - 1);
+ if (ss <= 0)
goto nothing;
+ buf[ss] = '\0';
ctl->possible_modes = strv_split(buf, " \n");
close(fd);
}
@@ -451,6 +454,7 @@ int main(int argc, char **argv)
static const ul_excl_t excl[] = {
{ 'a', 'l', 'u' },
{ 's', 't', OPT_DATE },
+ { 0 },
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;