diff --git a/modules/registrars/cozaepp/Net/EPP/Protocol.php b/modules/registrars/cozaepp/Net/EPP/Protocol.php
index ae2d69484b3e8444fee57b39a238582672aa755e..8c07df9ae59edb370585d0074636a6b0a6243e60 100644
--- a/modules/registrars/cozaepp/Net/EPP/Protocol.php
+++ b/modules/registrars/cozaepp/Net/EPP/Protocol.php
@@ -58,7 +58,6 @@ class Net_EPP_Protocol {
 				throw new exception('Timeout while reading from EPP Server');
 			}
 		}
-
 		// Check for timeout
 		if ($info['timed_out']) {
 			throw new Exception('Timeout while reading data from socket');
@@ -115,6 +114,9 @@ class Net_EPP_Protocol {
 	static function getFrame($socket) {
 		// Read header
 		$hdr = Net_EPP_Protocol::_fread_nb($socket,4);
+		if (strlen($hdr) < 4) {
+			throw new Exception(sprintf('Short read of %d bytes from peer', strlen($hdr)));
+		}
 
 		// Unpack first 4 bytes which is our length
 		$unpacked = unpack('N', $hdr);