From b8ff627be9abdb2c2c2283c66fac6267e0bdb966 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 30 Mar 2019 21:30:38 +0000 Subject: [PATCH] firmware: Fix kernel RPC tuple size calculation (memory corruption) Test case to follow. --- artiq/firmware/libproto_artiq/rpc_proto.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/artiq/firmware/libproto_artiq/rpc_proto.rs b/artiq/firmware/libproto_artiq/rpc_proto.rs index dfd1a1dfa..a7248be38 100644 --- a/artiq/firmware/libproto_artiq/rpc_proto.rs +++ b/artiq/firmware/libproto_artiq/rpc_proto.rs @@ -260,8 +260,9 @@ mod tag { Tag::ByteArray => 8, Tag::Tuple(it, arity) => { let mut size = 0; + let mut it = it.clone(); for _ in 0..arity { - let tag = it.clone().next().expect("truncated tag"); + let tag = it.next().expect("truncated tag"); size += tag.size(); } size