summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-25 19:36:10 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-25 19:36:29 +0100
commitd0a59e67fedf760a02109f5c18281241c6caa654 (patch)
tree3a5f8466eeb3529da9cabdff42aa26adcaeebd02
parentffdd90522aacaf19914c673f15e50f52137ada75 (diff)
Fix store_read calls
store_read takes a look at the size to determine whether to fill the provided buffer or not. Even if providing a null buffer we should set the size to 0. * defpager/defpager.c (pager_read_page): Initialize nread to 0. * storeio/dev.c (buffered_rw): Initialize amount to 0. * fatfs/fat.c (fat_read_sblock): Initialize read to the size of the boot sector. Reuse it as such.
-rw-r--r--defpager/defpager.c2
-rw-r--r--fatfs/fat.c7
-rw-r--r--storeio/dev.c2
3 files changed, 5 insertions, 6 deletions
diff --git a/defpager/defpager.c b/defpager/defpager.c
index f97b489c..3b3cda1e 100644
--- a/defpager/defpager.c
+++ b/defpager/defpager.c
@@ -58,7 +58,7 @@ pager_read_page (struct user_pager_info *pager,
int *write_lock)
{
int pfn = page / vm_page_size;
- size_t nread;
+ size_t nread = 0;
/* We never request write locks. */
*write_lock = 0;
diff --git a/fatfs/fat.c b/fatfs/fat.c
index e191cfc4..f31ce115 100644
--- a/fatfs/fat.c
+++ b/fatfs/fat.c
@@ -69,11 +69,10 @@ void
fat_read_sblock (void)
{
error_t err;
- size_t read;
+ size_t read = sizeof(struct boot_sector);
- sblock = malloc (sizeof (struct boot_sector));
- err = store_read (store, 0, sizeof (struct boot_sector),
- (void **) &sblock, &read);
+ sblock = malloc (read);
+ err = store_read (store, 0, read, (void **) &sblock, &read);
if (err)
error (1, err, "Could not read superblock");
diff --git a/storeio/dev.c b/storeio/dev.c
index 8726c94c..4f48d081 100644
--- a/storeio/dev.c
+++ b/storeio/dev.c
@@ -269,7 +269,7 @@ buffered_rw (struct dev *dev, off_t offs, size_t len, size_t *amount,
{
if (len >= block_size)
{
- size_t amount;
+ size_t amount = 0;
err = dev_buf_discard (dev);
if (! err)
err =