From 4c8d97cbd27db4f415f7bfde5474effcdedc27e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Sun, 8 Mar 2020 09:51:48 +0100 Subject: [PATCH] Fixed ntfsfallocate on a void file The situation when there were no runlist when ntfsfallocate is applied was not taken into account. --- ntfsprogs/ntfsfallocate.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ntfsprogs/ntfsfallocate.c b/ntfsprogs/ntfsfallocate.c index 7a2df7d1..d857922f 100644 --- a/ntfsprogs/ntfsfallocate.c +++ b/ntfsprogs/ntfsfallocate.c @@ -1,7 +1,7 @@ /** * ntfsfallocate * - * Copyright (c) 2013-2014 Jean-Pierre Andre + * Copyright (c) 2013-2020 Jean-Pierre Andre * * This utility will allocate clusters to a specified attribute belonging * to a specified file or directory, to a specified length. @@ -775,10 +775,14 @@ static int ntfs_fallocate(ntfs_inode *ni, s64 alloc_offs, s64 alloc_len) /* Get and save the initial allocations */ allocated_size = na->allocated_size; data_size = ni->data_size; - err = ntfs_attr_map_whole_runlist(na); + if (na->rl) + err = ntfs_attr_map_whole_runlist(na); if (!err) { - oldrl = ntfs_save_rl(na->rl); - if (oldrl) { + if (na->rl) + oldrl = ntfs_save_rl(na->rl); + else + oldrl = (runlist_element*)NULL; + if (!na->rl || oldrl) { err = ntfs_full_allocation(na, ctx, alloc_offs, alloc_len); if (err) {