aboutsummaryrefslogtreecommitdiffstats
path: root/passcheck.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-05 20:25:34 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-05 20:25:34 +0100
commit1472089e7ba64e9d9e4bcb70b359bbf32b7ed179 (patch)
treeca989dc7b7d5e13748c2524f78648c3ee5c668db /passcheck.py
parentupdate dist (diff)
downloadpasscheck-1472089e7ba64e9d9e4bcb70b359bbf32b7ed179.tar.gz
passcheck-1472089e7ba64e9d9e4bcb70b359bbf32b7ed179.tar.bz2
passcheck-1472089e7ba64e9d9e4bcb70b359bbf32b7ed179.tar.xz
fix use of pread1.5.1
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'passcheck.py')
-rwxr-xr-xpasscheck.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/passcheck.py b/passcheck.py
index fc76c53..b32f5b0 100755
--- a/passcheck.py
+++ b/passcheck.py
@@ -100,6 +100,15 @@ def search_cmp(haystack, needle):
if h == len(haystack):
return None if (too_low and too_high) else (-1 if too_low else 1)
+def pread_full(fd, bs, offset, output):
+ got_total = 0
+ while got_total < bs:
+ got = list(os.pread(fd, bs - got_total, offset + got_total))
+ if len(got) == 0:
+ break
+ got_total += len(got)
+ output.extend(got)
+
def search_file(fd, filesize, passphrase):
blocksize = 4096
minimum = 0
@@ -112,7 +121,7 @@ def search_file(fd, filesize, passphrase):
continues = 0
data = []
while True:
- data.extend(list(os.pread(fd, blocksize, middle + continues * blocksize)))
+ pread_full(fd, blocksize, middle + continues * blocksize, data)
if middle_low is None:
middle_low = 0
if middle > 0: