From 9179cc6c753512cac8536d81773723cf67bac605 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 14 Nov 2018 00:26:35 +0000 Subject: [PATCH] With "-s" specified, cope with empty or missing state file. --- clunk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clunk.c b/clunk.c index cbb8efb..2ff3b44 100644 --- a/clunk.c +++ b/clunk.c @@ -100,8 +100,10 @@ init_statefile(char const *statefilename) len = pread(statefd, buf, 9, 0); if (len == -1) err(1, "read %s", optarg); - buf[len] = '\0'; - init_statestring(buf); + if (len > 0) { + buf[len] = '\0'; + init_statestring(buf); + } } static void -- 2.30.2