]> git.lizzy.rs Git - plan9front.git/commitdiff
cpu: properly handle end of file in readstr()
authorcinap_lenrek <cinap_lenrek@felloff.net>
Tue, 4 May 2021 23:50:09 +0000 (01:50 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Tue, 4 May 2021 23:50:09 +0000 (01:50 +0200)
sys/src/cmd/cpu.c

index 3fb3a6d5efc6517e1b8f29db7df0b1cd7728633c..f4083f3155531a9f7b692d210da01695a2ac758d 100644 (file)
@@ -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++;