aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-08-16 22:52:15 +0000
committerChristian Grothoff <christian@grothoff.org>2012-08-16 22:52:15 +0000
commit6b18d819ffe42b3dc1611bb4abc16c5b51c610b6 (patch)
tree089a8f293e67a8de1ad41c44797baab2d09df3f4
parent79585dea037e35066eb58c3a13b42c5b39d966df (diff)
downloadlibextractor-6b18d819ffe42b3dc1611bb4abc16c5b51c610b6.tar.gz
libextractor-6b18d819ffe42b3dc1611bb4abc16c5b51c610b6.zip
fixes
-rw-r--r--src/main/extractor_datasource.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c
index c01e62a..e6eaee6 100644
--- a/src/main/extractor_datasource.c
+++ b/src/main/extractor_datasource.c
@@ -117,19 +117,20 @@ struct BufferedFileDataSource
117 uint64_t fpos; 117 uint64_t fpos;
118 118
119 /** 119 /**
120 * Position within the buffer. 120 * Position within the buffer. Our absolute offset in the file
121 * is thus 'fpos + buffer_pos'.
121 */ 122 */
122 uint64_t buffer_pos; 123 size_t buffer_pos;
123 124
124 /** 125 /**
125 * Number of valid bytes in the buffer (<= buffer_size) 126 * Number of valid bytes in the buffer (<= buffer_size)
126 */ 127 */
127 uint64_t buffer_bytes; 128 size_t buffer_bytes;
128 129
129 /** 130 /**
130 * Allocated size of the buffer 131 * Allocated size of the buffer
131 */ 132 */
132 uint64_t buffer_size; 133 size_t buffer_size;
133 134
134 /** 135 /**
135 * Descriptor of the file to read data from (may be -1) 136 * Descriptor of the file to read data from (may be -1)
@@ -377,8 +378,8 @@ bfds_seek (struct BufferedFileDataSource *bfds,
377 return -1; 378 return -1;
378 } 379 }
379 if ( (NULL == bfds->buffer) || 380 if ( (NULL == bfds->buffer) ||
380 ( (bfds->buffer_pos + bfds->fpos <= pos) && 381 ( (bfds->fpos <= pos) &&
381 (bfds->buffer_pos + bfds->fpos + bfds->buffer_bytes > pos) ) ) 382 (bfds->fpos + bfds->buffer_bytes > pos) ) )
382 { 383 {
383 bfds->buffer_pos = pos - bfds->fpos; 384 bfds->buffer_pos = pos - bfds->fpos;
384 return pos; 385 return pos;