Fix integer overflow in prpc.c response->length calculation (#321)
RPC commands tested, daemon works
This commit is contained in:
parent
d0d9ac2d77
commit
0ae4882ada
|
|
@ -219,12 +219,12 @@ static void respond(rpc_message_t *request, rpc_message_t *response) {
|
||||||
|
|
||||||
// truncate messages that exceed the buffer boundaries
|
// truncate messages that exceed the buffer boundaries
|
||||||
size_t value_length = strnlen(response->value, value_avail);
|
size_t value_length = strnlen(response->value, value_avail);
|
||||||
response->length = sizeof(rpc_message_t) + value_length + 1;
|
if (value_length > POVERLAY_BUFSIZE - sizeof(rpc_message_t) - 1) {
|
||||||
if (response->length > POVERLAY_BUFSIZE) {
|
value_length = POVERLAY_BUFSIZE - sizeof(rpc_message_t) - 1;
|
||||||
response->length = POVERLAY_BUFSIZE;
|
response->value[value_length] = '\0';
|
||||||
response->value[value_avail - 1] = '\0';
|
|
||||||
pdbg_logf(D_WARNING, "Response message truncated to fit buffer");
|
pdbg_logf(D_WARNING, "Response message truncated to fit buffer");
|
||||||
}
|
}
|
||||||
|
response->length = sizeof(rpc_message_t) + value_length + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prpc_main_loop() {
|
void prpc_main_loop() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue