From d0a59e67fedf760a02109f5c18281241c6caa654 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 25 Feb 2022 19:36:10 +0100 Subject: 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. --- fatfs/fat.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'fatfs') 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"); -- cgit v1.2.3