git: improve error on short read

we don't recover from an invalid packet, so just
sysfatal with a useful message.
This commit is contained in:
Ori Bernstein 2022-05-20 17:16:41 +00:00
parent f87c5f7f43
commit 408242edcf

View file

@ -58,8 +58,8 @@ readpkt(Conn *c, char *buf, int nbuf)
char *e; char *e;
int n; int n;
if(readn(c->rfd, len, 4) == -1) if(readn(c->rfd, len, 4) != 4)
return -1; sysfatal("pktline: short read from transport");
len[4] = 0; len[4] = 0;
n = strtol(len, &e, 16); n = strtol(len, &e, 16);
if(n == 0){ if(n == 0){