mirror of git://git.sysmocom.de/ofono
simfs: Fix the number of bytes copied
In block reading operations we read too much when the number of bytes to read is smaller than the size of the file.
This commit is contained in:
parent
e755292874
commit
bd8c7e92bb
|
@ -227,12 +227,13 @@ static void sim_fs_op_read_block_cb(const struct ofono_error *error,
|
|||
if (op->current == start_block) {
|
||||
bufoff = 0;
|
||||
dataoff = op->offset % 256;
|
||||
tocopy = MIN(256 - op->offset % 256, len);
|
||||
tocopy = MIN(256 - op->offset % 256,
|
||||
op->num_bytes - op->current * 256);
|
||||
} else {
|
||||
bufoff = (op->current - start_block - 1) * 256 +
|
||||
op->offset % 256;
|
||||
dataoff = 0;
|
||||
tocopy = len;
|
||||
tocopy = MIN(256, op->num_bytes - op->current * 256);
|
||||
}
|
||||
|
||||
DBG("bufoff: %d, dataoff: %d, tocopy: %d",
|
||||
|
@ -290,12 +291,12 @@ static gboolean sim_fs_op_read_block(gpointer user_data)
|
|||
seekoff = SIM_CACHE_HEADER_SIZE + op->current * 256 +
|
||||
op->offset % 256;
|
||||
toread = MIN(256 - op->offset % 256,
|
||||
op->length - op->current * 256);
|
||||
op->num_bytes - op->current * 256);
|
||||
} else {
|
||||
bufoff = (op->current - start_block - 1) * 256 +
|
||||
op->offset % 256;
|
||||
seekoff = SIM_CACHE_HEADER_SIZE + op->current * 256;
|
||||
toread = MIN(256, op->length - op->current * 256);
|
||||
toread = MIN(256, op->num_bytes - op->current * 256);
|
||||
}
|
||||
|
||||
DBG("bufoff: %d, seekoff: %d, toread: %d",
|
||||
|
|
Loading…
Reference in New Issue