From 956b25dfeb5408063fedac8d27bda541d52ee120 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sun, 21 Jan 2018 21:56:29 +0000 Subject: [PATCH] fix read_cstring incorrectly setting offset --- steam/util/binary.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/steam/util/binary.py b/steam/util/binary.py index 4dd1f68..9c5b6a9 100644 --- a/steam/util/binary.py +++ b/steam/util/binary.py @@ -42,7 +42,9 @@ class StructReader(object): :rtype: :class:`bytes` """ null_index = self.data.find(terminator, self.offset) - result = self.data[self.offset:null_index] # bytes without the terminator + if null_index == -1: + raise RuntimeError("Reached end of buffer") + result = self.data[self.offset:null_index] # bytes without the terminator self.offset = null_index + len(terminator) # advance offset past terminator return result