summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-05-05 01:50:09 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2021-05-05 01:50:09 +0200
commit7c1e0be91969ab0d8fca4bd1fd52de32f4a9a0c5 (patch)
tree0d8f1316cb4ef39c50303fc1adbf59e3931de2af
parentee289c241577a3553bfd73211cd81e137ab4fe40 (diff)
downloadplan9front-7c1e0be91969ab0d8fca4bd1fd52de32f4a9a0c5.tar.xz
cpu: properly handle end of file in readstr()
-rw-r--r--sys/src/cmd/cpu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c
index 3fb3a6d5e..f4083f315 100644
--- a/sys/src/cmd/cpu.c
+++ b/sys/src/cmd/cpu.c
@@ -430,6 +430,10 @@ readstr(int fd, char *str, int len)
n = read(fd, str, 1);
if(n < 0)
return -1;
+ if(n == 0){
+ werrstr("hung up");
+ return -1;
+ }
if(*str == '\0')
return 0;
str++;