[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Integer truncation could break reader's last modified check
commit 975d98d7337d4dd566aa5e9967e62afe2fdb0bc0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Mar 25 16:12:32 2012 -0700
Integer truncation could break reader's last modified check
When saving the last modified timestamps they're saved as ints. However, the
timestamp itself is a float, so the following check for an unchanging timestamp
would fail.
---
stem/descriptor/reader.py | 2 +-
test/integ/descriptor/reader.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 61bee5c..4683744 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -326,7 +326,7 @@ class DescriptorReader:
# This is a file. Register it's last modified timestamp and check if
# it's a file that we should skip.
- last_modified = os.stat(target).st_mtime
+ last_modified = int(os.stat(target).st_mtime)
last_used = self._processed_files.get(target)
if last_used and last_used >= last_modified:
diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index 717a55b..1444dbb 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -279,7 +279,7 @@ class TestDescriptorReader(unittest.TestCase):
for root, _, files in os.walk(DESCRIPTOR_TEST_DATA):
for filename in files:
path = os.path.join(root, filename)
- last_modified = os.stat(path).st_mtime
+ last_modified = int(os.stat(path).st_mtime)
expected_results[path] = last_modified
reader = stem.descriptor.reader.DescriptorReader([DESCRIPTOR_TEST_DATA])
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits