From c1251cdd510402ff24572e187f089c5b87cb7e98 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 25 Jul 2002 06:34:48 +0000 Subject: Added error checking to middle of file reading, security fix for resuming git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@174 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/src/Security.py | 2 +- rdiff-backup/src/iterfile.py | 11 ++++++++++- rdiff-backup/src/robust.py | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'rdiff-backup/src') diff --git a/rdiff-backup/src/Security.py b/rdiff-backup/src/Security.py index 49857ab..7f193aa 100644 --- a/rdiff-backup/src/Security.py +++ b/rdiff-backup/src/Security.py @@ -108,6 +108,7 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["C.make_file_dict", "os.getuid", "os.listdir", + "Time.setcurtime_local", "Resume.ResumeCheck", "HLSourceStruct.split_initial_dsiter", "HLSourceStruct.get_diffs_and_finalize"]) @@ -127,7 +128,6 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["SetConnections.init_connection_remote", "Log.setverbosity", "Log.setterm_verbosity", - "Time.setcurtime_local", "Time.setprevtime_local", "FilenameMapping.set_init_quote_vals_local", "Globals.postset_regexp_local", diff --git a/rdiff-backup/src/iterfile.py b/rdiff-backup/src/iterfile.py index c90229e..5549ca8 100644 --- a/rdiff-backup/src/iterfile.py +++ b/rdiff-backup/src/iterfile.py @@ -190,12 +190,20 @@ class FileWrappingIter: def addfromfile(self): """Read a chunk from the current file and return it""" - buf = self.currently_in_file.read(Globals.blocksize) + # Check file read for errors, buf = "" if find one + buf = Robust.check_common_error(self.read_error_handler, + self.currently_in_file.read, + [Globals.blocksize]) if not buf: assert not self.currently_in_file.close() self.currently_in_file = None return C.long2str(long(len(buf))) + buf + def read_error_handler(self, exc, blocksize): + """Log error when reading from file""" + Log("Error '%s' reading from fileobj, truncating" % (str(exc),), 2) + return "" + def _l2s_old(self, l): """Convert long int to string of 7 characters""" s = "" @@ -237,3 +245,4 @@ class BufferedRead: def close(self): return self.file.close() from log import * +from robust import * diff --git a/rdiff-backup/src/robust.py b/rdiff-backup/src/robust.py index 5e2ee96..1973cc3 100644 --- a/rdiff-backup/src/robust.py +++ b/rdiff-backup/src/robust.py @@ -575,7 +575,10 @@ class Resume: mirror = None last_index = cls.sym_to_index(increment_sym) if checkpoint_rp: - ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + result = cls.unpickle_checkpoint(checkpoint_rp) + sys.stderr.write("#############" + str(result) + "\n") + #ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + ITR, finalizer = result elif mirror_sym: mirror = 1 last_index = cls.sym_to_index(mirror_sym) @@ -609,6 +612,7 @@ class Resume: try: result = cPickle.loads(data) except cPickle.UnpicklingError: raise ResumeException("Bad pickle at %s" % (checkpoint_rp.path,)) + return result def ResumeCheck(cls): """Return relevant ResumeSessionInfo if there's one we should resume -- cgit v1.2.1