From 910a63f28aad5e9448b802c6c104e409829115a1 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Mon, 14 Jan 2008 01:33:36 +0100 Subject: [PATCH] Fix little bug related with dir length calculation. --- src/ecma119.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ecma119.c b/src/ecma119.c index 41bcdc5..770f0c2 100644 --- a/src/ecma119.c +++ b/src/ecma119.c @@ -130,6 +130,14 @@ size_t calc_dir_size(Ecma119Image *t, Ecma119Node *dir, size_t *ce) len += dirent_len; } } + + /* + * The size of a dir is always a multiple of block size, as we must add + * the size of the unused space after the last directory record + * (ECMA-119, 6.8.1.3) + */ + len = div_up(len, BLOCK_SIZE) * BLOCK_SIZE; + /* cache the len */ dir->info.dir->len = len; return len;