libventi: fix segfault in vtreadpacket when not connected
This problem happens especially in fossil/view when vtread can be called even if not connected to venti. The old libventi handle this case properly in the function vtRPC, which is called by vtReadPacket (client.c). R=rsc CC=plan9port.codebot http://codereview.appspot.com/5484044
This commit is contained in:
parent
ca81de0ae1
commit
73392c2c7c
1 changed files with 5 additions and 0 deletions
|
|
@ -65,6 +65,11 @@ vtreadpacket(VtConn *z, uchar score[VtScoreSize], uint type, int n)
|
||||||
if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
|
if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
|
||||||
return packetalloc();
|
return packetalloc();
|
||||||
|
|
||||||
|
if(z == nil){
|
||||||
|
werrstr("not connected");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
if(z->version[1] == '2' && n >= (1<<16)) {
|
if(z->version[1] == '2' && n >= (1<<16)) {
|
||||||
werrstr("read count too large for protocol");
|
werrstr("read count too large for protocol");
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue