session.c: ensure session reset on out buffer overrun during RPC.

This commit is contained in:
whitequark 2015-08-08 14:12:28 +03:00
parent f5ea202e25
commit 1d61e446cb
1 changed files with 12 additions and 6 deletions

View File

@ -474,7 +474,8 @@ static int process_input(void)
static int send_rpc_value(const char **tag, void *value) static int send_rpc_value(const char **tag, void *value)
{ {
out_packet_int8(**tag); if(!out_packet_int8(**tag))
return -1;
int size = 0; int size = 0;
switch(**tag) { switch(**tag) {
@ -484,23 +485,27 @@ static int send_rpc_value(const char **tag, void *value)
case 'b': // bool case 'b': // bool
size = 1; size = 1;
out_packet_chunk(value, size); if(!out_packet_chunk(value, size))
return -1;
break; break;
case 'i': // int(width=32) case 'i': // int(width=32)
size = 4; size = 4;
out_packet_chunk(value, size); if(!out_packet_chunk(value, size))
return -1;
break; break;
case 'I': // int(width=64) case 'I': // int(width=64)
case 'f': // float case 'f': // float
size = 8; size = 8;
out_packet_chunk(value, size); if(!out_packet_chunk(value, size))
return -1;
break; break;
case 'F': // Fraction case 'F': // Fraction
size = 16; size = 16;
out_packet_chunk(value, size); if(!out_packet_chunk(value, size))
return -1;
break; break;
case 'l': { // list(elt='a) case 'l': { // list(elt='a)
@ -604,7 +609,7 @@ static int process_kmsg(struct msg_base *umsg)
if(!send_rpc_request(msg->rpc_num, msg->args)) { if(!send_rpc_request(msg->rpc_num, msg->args)) {
log("Failed to send RPC request"); log("Failed to send RPC request");
return 0; return 0; // restart session
} }
user_kernel_state = USER_KERNEL_WAIT_RPC; user_kernel_state = USER_KERNEL_WAIT_RPC;
@ -617,6 +622,7 @@ static int process_kmsg(struct msg_base *umsg)
umsg->type); umsg->type);
return 0; return 0;
} }
return 1; return 1;
} }