cpu: properly handle end of file in readstr()

cinap_lenrek 2021-05-05 01:50:09 +02:00
parent ee289c2415
commit 7c1e0be919
1 changed files with 4 additions and 0 deletions

View 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++;