Commits

Erik Grinaker committed 1c557d1

fix crash in Password Safe import/export with fields longer than 256 chars

  • Participants
  • Parent commits d887683

Comments (0)

Files changed (3)

 	* strip xml entities from password on clipboard copy or
 	drag/drop
 
+	* fix crash in Password Safe import/export with fields longer
+	than 256 chars
+
 2006-01-19  Erik Grinaker <erikg@codepoet.no>
 
 	* fixed drag and drop undo/redo crashes
 - fixed drag and drop undo/redo crashes
 - don't initialize python modules during configure checks
 - strip xml entities from password on clipboard copy or drag/drop
+- fix crash in Password Safe import/export with fields longer than 256 chars
 - changed button "Edit" to "Update" in edit entry dialog
 - use full path when starting Revelation from applet
 - use correct key path for applet show_passwords gconf schema key

File src/lib/datahandler/pwsafe.py

 def create_field(value, type = FIELDTYPE_NAME):
 	"Creates a field"
 
-	field = ""
-	field += "".join([ chr(len(value) >> i * 8) for i in range(4) ])
-	field += "".join([ chr(type >> i * 8) for i in range(4) ])
-	field += value
+	field = struct.pack("ii", len(value), type) + value
 
 	if len(value) == 0 or len(value) % 8 != 0:
 		field += "\x00" * (8 - len(value) % 8)
 	if len(header) < 8:
 		raise base.FormatError
 
-	# get length
-	length = ord(header[0]) << 0 | ord(header[1]) << 8 | ord(header[2]) << 16 | ord(header[3]) << 24
+	length, type = struct.unpack("ii", header[:8])
 
 	if length == 0 or length % 8 != 0:
 		length += 8 - length % 8
 
-	# get type
-	type = ord(header[4]) << 0 | ord(header[5]) << 8 | ord(header[6]) << 16 | ord(header[7]) << 24
-
 	return length, type