Index: server/lib/ipprequest.py
===================================================================
--- server/lib/ipprequest.py	(revision aaa1da3a9fd6a242e89c8fffcd352a802a36a0d9)
+++ server/lib/ipprequest.py	(revision 89fe6da64d20b0dc45e1a9249bdaf5e07e86943d)
@@ -420,5 +420,5 @@
     # can be read from to get the request
     def __init__(self, version=None, operation_id=None, request_id=None,
-                 attribute_groups=[], data=None, request=None):
+                 attribute_groups=[], data=None, request=None, length=sys.maxint):
         """
         Create an IPPRequest.  Takes either the segments of the
@@ -469,4 +469,5 @@
             # read the version-number (two signed chars)
             self.version        = struct.unpack('>bb', request.read(2))
+            length -= 2
             logger.debug("version-number : (0x%X, 0x%X)" % self.version)
 
@@ -474,8 +475,10 @@
             # for a response) (signed short)
             self.operation_id   = struct.unpack('>h', request.read(2))[0]
+            length -= 2
             logger.debug("operation-id : 0x%X" % self.operation_id)
 
             # read the request-id (signed int)
             self.request_id     = struct.unpack('>i', request.read(4))[0]
+            length -= 4
             logger.debug("request-id : 0x%X" % self.request_id)
 
@@ -486,4 +489,5 @@
             # read in the next byte
             next_byte = struct.unpack('>b', request.read(1))[0]
+            length -=1
             logger.debug("next byte : 0x%X" % next_byte)
 
@@ -498,4 +502,5 @@
 
                 next_byte = struct.unpack('>b', request.read(1))[0]
+                length -= 1
                 logger.debug("next byte : 0x%X" % next_byte)
 
@@ -508,4 +513,5 @@
                     # read in the length of the name (signed short)
                     name_length   = struct.unpack('>h', request.read(2))[0]
+                    length -= 2
                     logger.debug("name-length : %i" % name_length)
                     
@@ -513,13 +519,16 @@
                         # read the name (a string of name_length bytes)
                         name          = request.read(name_length)
+                        length -= name_length
                         logger.debug("name : %s" % name)
                     
                         # read in the length of the value (signed short)
                         value_length  = struct.unpack('>h', request.read(2))[0]
+                        length -= 2
                         logger.debug("value-length : %i" % value_length)
                     
                         # read in the value (string of value_length bytes)
                         value         = request.read(value_length)
-
+                        length -= value_length
+                        
                         ippvalue = IPPValue(value_tag, value)
                         logger.debug("value : %s" % ippvalue.value)
@@ -532,8 +541,10 @@
                         # read in the length of the value (signed short)
                         value_length  = struct.unpack('>h', request.read(2))[0]
+                        length -= 2
                         logger.debug("value-length : %i" % value_length)
                     
                         # read in the value (string of value_length bytes)
                         value         = request.read(value_length)
+                        length -= value_length
 
                         ippvalue = IPPValue(value_tag, value)
@@ -545,4 +556,5 @@
                     # read another byte
                     next_byte = struct.unpack('>b', request.read(1))[0]
+                    length -= 1
 
                 self.attribute_groups.append(IPPAttributeGroup(attribute_group_tag, attributes))
@@ -550,5 +562,6 @@
             # once we hit the end-of-attributes tag, the only thing
             # left is the data, so go ahead and read all of it
-            self.data = request.read()
+            assert length >= 0
+            self.data = request.read(length)
             logger.debug("data : %s" % self.data)
 
Index: server/lib/server.py
===================================================================
--- server/lib/server.py	(revision 478ca741a8bc89297c6c61beada6bcff5624c1f2)
+++ server/lib/server.py	(revision 89fe6da64d20b0dc45e1a9249bdaf5e07e86943d)
@@ -17,5 +17,6 @@
 
     def handle_ipp(self):
-        req = ipprequest.IPPRequest(request=self.rfile, length=self.headers.getheader('content-length', 0))
+        req = ipprequest.IPPRequest(request=self.rfile,
+                                    length=self.headers.getheader('content-length', 0))
 
         self.send_response(200, "o hai")
