forked from M-Labs/artiq
comm_kernel: check if elements are within bounds for RPC list (#1824)
This commit is contained in:
parent
4eee49f889
commit
de5892a00a
|
@ -476,11 +476,19 @@ class CommKernel:
|
||||||
if tag_element == "b":
|
if tag_element == "b":
|
||||||
self._write(bytes(value))
|
self._write(bytes(value))
|
||||||
elif tag_element == "i":
|
elif tag_element == "i":
|
||||||
self._write(struct.pack(self.endian + "%sl" %
|
try:
|
||||||
len(value), *value))
|
self._write(struct.pack(self.endian + "%sl" % len(value), *value))
|
||||||
|
except struct.error:
|
||||||
|
raise RPCReturnValueError(
|
||||||
|
"type mismatch: cannot serialize {value} as {type}".format(
|
||||||
|
value=repr(value), type="32-bit integer list"))
|
||||||
elif tag_element == "I":
|
elif tag_element == "I":
|
||||||
self._write(struct.pack(self.endian + "%sq" %
|
try:
|
||||||
len(value), *value))
|
self._write(struct.pack(self.endian + "%sq" % len(value), *value))
|
||||||
|
except struct.error:
|
||||||
|
raise RPCReturnValueError(
|
||||||
|
"type mismatch: cannot serialize {value} as {type}".format(
|
||||||
|
value=repr(value), type="64-bit integer list"))
|
||||||
elif tag_element == "f":
|
elif tag_element == "f":
|
||||||
self._write(struct.pack(self.endian + "%sd" %
|
self._write(struct.pack(self.endian + "%sd" %
|
||||||
len(value), *value))
|
len(value), *value))
|
||||||
|
|
Loading…
Reference in New Issue