chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b788cc2
)
journal: apply seek check before resizing window, and refresh stat data if necessary
author
Lennart Poettering
<lennart@poettering.net>
Wed, 4 Jan 2012 01:16:38 +0000
(
02:16
+0100)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 4 Jan 2012 01:16:38 +0000
(
02:16
+0100)
src/journal/journal-file.c
patch
|
blob
|
history
diff --git
a/src/journal/journal-file.c
b/src/journal/journal-file.c
index 15a752d507eae8892e92ae7931dd3d562347a28c..977cfa1010f8a57ae057a4b3412e65c907368d0a 100644
(file)
--- a/
src/journal/journal-file.c
+++ b/
src/journal/journal-file.c
@@
-296,6
+296,15
@@
static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_
assert(wt >= 0);
assert(wt < _WINDOW_MAX);
assert(wt >= 0);
assert(wt < _WINDOW_MAX);
+ if (offset + size > (uint64_t) f->last_stat.st_size) {
+ /* Hmm, out of range? Let's refresh the fstat() data
+ * first, before we trust that check. */
+
+ if (fstat(f->fd, &f->last_stat) < 0 ||
+ offset + size > (uint64_t) f->last_stat.st_size)
+ return -EADDRNOTAVAIL;
+ }
+
w = f->windows + wt;
if (_likely_(w->ptr &&
w = f->windows + wt;
if (_likely_(w->ptr &&
@@
-331,9
+340,6
@@
static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_
} else
delta = 0;
} else
delta = 0;
- if (offset > (uint64_t) f->last_stat.st_size)
- return -EADDRNOTAVAIL;
-
if (offset + size > (uint64_t) f->last_stat.st_size)
size = PAGE_ALIGN((uint64_t) f->last_stat.st_size - offset);
if (offset + size > (uint64_t) f->last_stat.st_size)
size = PAGE_ALIGN((uint64_t) f->last_stat.st_size - offset);