diff options
author | Geremy Condra <gcondra@google.com> | 2014-04-05 15:41:51 -0700 |
---|---|---|
committer | Geremy Condra <gcondra@google.com> | 2014-04-05 16:36:03 -0700 |
commit | 50ac04caf96aedb31e9a93d02d50805cd3702272 (patch) | |
tree | fb009109eb23b14a1ae7c518c1f77f2375cc403e | |
parent | d92658ddf89ca3525412bf3becb7e98bedb6fc8b (diff) | |
download | syspatch-50ac04caf96aedb31e9a93d02d50805cd3702272.tar.gz |
Fix erroneous READ_FRONTIER checks.
READ_FRONTIER is intended to ensure that data needed to produce a
target window isn't inadvertently clobbered by an earlier write.
Check this by actually looking at the source and target windows
being read/written rather than the current location in the file.
Change-Id: I31ad10365dd5a5a6bf4142b288a0c3ea846b6b9b
-rw-r--r-- | syspatch.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -124,7 +124,7 @@ static SourceRead *get_source_window_from_file(xd3_source *source) { MapState* state = (MapState*) source->ioh; source_read->blkno = source->getblkno; source_read->length = read_with_map(source_read->data, sizeof(source_read->data), state); - if (ftell(state->f) < READ_FRONTIER) { + if (read_position < READ_FRONTIER) { fprintf(stderr, "read past frontier: %ld > %zu\n", ftell(state->f), READ_FRONTIER); return NULL; } @@ -180,7 +180,7 @@ static int write_target(TargetWrite *tgt, MapState *target_state) { return -1; } } - READ_FRONTIER = ftell(target_state->f); + READ_FRONTIER = tgt->start + tgt->length; return 0; } |