[Zodb-checkins] CVS: Zope2/lib/python/ZODB - FileStorage.py:1.54

Jim Fulton jim@digicool.com
Thu, 12 Apr 2001 19:38:25 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/ZODB
In directory korak:/tmp/cvs-serv10215

Modified Files:
	FileStorage.py 
Log Message:
Added checks for empty strings in commit/abortVersion and
versionEmpty.



--- Updated File FileStorage.py in package Zope2/lib/python/ZODB --
--- FileStorage.py	2001/04/12 20:50:23	1.53
+++ FileStorage.py	2001/04/12 23:38:25	1.54
@@ -203,6 +203,8 @@
 try: from posix import fsync
 except: fsync=None
 
+StringType=type('')
+
 z64='\0'*8
 
 def warn(message, *data):
@@ -450,6 +452,11 @@
     def commitVersion(self, src, dest, transaction, abort=None):
         # We are going to commit by simply storing back pointers.
 
+        if (not src or
+            type(src) is not StringType or type(dest) is not StringType
+            ):
+            raise POSException.VersionCommitError('Invalid source version')
+
         if dest and abort:
             raise 'VersionCommitError', (
                 'Internal error, can\'t abort to a version')
@@ -1074,6 +1081,13 @@
         finally: self._lock_release()
 
     def versionEmpty(self, version):
+        if not version:
+            # The interface is silent on this case. I think that this should
+            # be an error, but Barry thinks this should return 1 if we have
+            # any non-version data. This would be excruciatingly painful to
+            # test, so I must be right. ;)
+            raise POSException.VersionError(
+                'The version must be an non-empty string')
         self._lock_acquire()
         try:
             index=self._index