]> granicus.if.org Git - python/commitdiff
Add a length check to aifc to ensure it doesn't write a bogus file
authorBob Ippolito <bob@redivi.com>
Tue, 30 May 2006 00:26:01 +0000 (00:26 +0000)
committerBob Ippolito <bob@redivi.com>
Tue, 30 May 2006 00:26:01 +0000 (00:26 +0000)
Lib/aifc.py

index 781d77cee400d75002e5db7db9008cecca2df8e2..a5f86be455b5ffa302384bd1efceae3ef7de67dc 100644 (file)
@@ -201,6 +201,8 @@ def _write_long(f, x):
     f.write(struct.pack('>L', x))
 
 def _write_string(f, s):
+    if len(s) > 255:
+        raise ValueError("string exceeds maximum pstring length")
     f.write(chr(len(s)))
     f.write(s)
     if len(s) & 1 == 0: