From: Ben Harris Date: Wed, 14 Nov 2018 00:26:35 +0000 (+0000) Subject: With "-s" specified, cope with empty or missing state file. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=9179cc6c753512cac8536d81773723cf67bac605;p=clunk.git With "-s" specified, cope with empty or missing state file. --- 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