Commit 72174f79 authored by Jim Fulton's avatar Jim Fulton

Added checks for empty strings in commit/abortVersion and

versionEmpty.
parent 259903e6
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.53 $'[11:-2] __version__='$Revision: 1.54 $'[11:-2]
import struct, time, os, bpthread, string, base64, sys import struct, time, os, bpthread, string, base64, sys
from struct import pack, unpack from struct import pack, unpack
...@@ -203,6 +203,8 @@ import ConflictResolution ...@@ -203,6 +203,8 @@ import ConflictResolution
try: from posix import fsync try: from posix import fsync
except: fsync=None except: fsync=None
StringType=type('')
z64='\0'*8 z64='\0'*8
def warn(message, *data): def warn(message, *data):
...@@ -450,6 +452,11 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -450,6 +452,11 @@ class FileStorage(BaseStorage.BaseStorage,
def commitVersion(self, src, dest, transaction, abort=None): def commitVersion(self, src, dest, transaction, abort=None):
# We are going to commit by simply storing back pointers. # 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: if dest and abort:
raise 'VersionCommitError', ( raise 'VersionCommitError', (
'Internal error, can\'t abort to a version') 'Internal error, can\'t abort to a version')
...@@ -1074,6 +1081,13 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -1074,6 +1081,13 @@ class FileStorage(BaseStorage.BaseStorage,
finally: self._lock_release() finally: self._lock_release()
def versionEmpty(self, version): 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() self._lock_acquire()
try: try:
index=self._index index=self._index
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment