aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-03-16 16:09:39 +0000
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-03-16 16:19:25 +0000
commite22c803cbdcdb6565b9d8bfd6a1a2407e92e6246 (patch)
tree183d3b5ab478ab6915a79e16b44474506e13e077
parent251bd0850e932e1cb36a77c5db3e55c2426f3577 (diff)
downloadsail-riscv-e22c803cbdcdb6565b9d8bfd6a1a2407e92e6246.zip
sail-riscv-e22c803cbdcdb6565b9d8bfd6a1a2407e92e6246.tar.gz
sail-riscv-e22c803cbdcdb6565b9d8bfd6a1a2407e92e6246.tar.bz2
Check for overly large RVFI packets
-rw-r--r--c_emulator/riscv_sim.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c
index 71863cb..4fbeb07 100644
--- a/c_emulator/riscv_sim.c
+++ b/c_emulator/riscv_sim.c
@@ -683,6 +683,7 @@ static void get_and_send_rvfi_packet(packet_reader_fn *reader) {
lbits packet;
CREATE(lbits)(&packet);
reader(&packet, UNIT);
+ /* Note: packet.len is the size in bits, not bytes. */
if (packet.len % 8 != 0) {
fprintf(stderr, "RVFI-DII trace packet not byte aligned: %d\n", (int)packet.len);
exit(1);
@@ -692,6 +693,10 @@ static void get_and_send_rvfi_packet(packet_reader_fn *reader) {
print_bits("packet = ", packet);
fprintf(stderr, "Sending packet with length %zd... ", send_size);
}
+ if (send_size > 4096) {
+ fprintf(stderr, "Unexpected large packet size (> 4KB): %zd\n", send_size);
+ exit(1);
+ }
unsigned char bytes[send_size];
/* mpz_export might not write all of the null bytes */
memset(bytes, 0, sizeof(bytes));