diff --git a/srb2query.php b/srb2query.php
index 94cdaeb3c36e7a739bfa851fb5a0f6ac36047c54..0d39ff5916e95d05d26391f81fbe1b424ea381e1 100644
--- a/srb2query.php
+++ b/srb2query.php
@@ -386,7 +386,7 @@ class SRB2Query
 		// I can get away with just 'minimum' for now because there aren't any
 		// variable length packets in array format. That sounds stupid anyway.
 		$n = $n * $pkf['minimum'];
-		if ($n > strlen($pk['buffer']))
+		if ($n + $pkf['minimum'] > strlen($pk['buffer']))
 			return FALSE;
 		$t = unpack($pkf['format'], $pk['buffer'], $n);
 		if (isset($pkf['strings']))