Merge branch 'develop' into '35-incorrect-struct-type-used-in-readwrite-c'

# Conflicts:
#   debian/changelog
This commit is contained in:
Patrick J Cherry
2018-02-09 11:29:48 +00:00
4 changed files with 33 additions and 0 deletions

View File

@@ -97,6 +97,15 @@ int open_and_mmap(const char* filename, int* out_fd, uint64_t *out_size, void **
warn("lseek64() failed");
return size;
}
/* If discs are not in multiples of 512, then odd things happen,
* resulting in reads/writes past the ends of files.
*/
if ( size != (size & (~0x1ff))) {
warn("file does not fit into 512-byte sectors; the end of the file will be ignored.");
size &= ~0x1ff;
}
if (out_size) {
*out_size = size;
}

View File

@@ -710,6 +710,15 @@ void serve_init_allocation_map(struct server* params)
FATAL_IF_NEGATIVE(fd, "Couldn't open %s", params->filename );
size = lseek64( fd, 0, SEEK_END );
/* If discs are not in multiples of 512, then odd things happen,
* resulting in reads/writes past the ends of files.
*/
if ( size != (size & ~0x1ff)) {
warn("file does not fit into 512-byte sectors; the end of the file will be ignored.");
size &= ~0x1ff;
}
params->size = size;
FATAL_IF_NEGATIVE( size, "Couldn't find size of %s",
params->filename );