Hi, the attached patches 1-4 fix what look like potential problems to me, 5-10 fix clang warnings but the issues should be harmless.
I'm not sure about this code from libntfs-3g/attrib.c:
5328 if (bytes_read != na->initialized_size) {
5329 if (bytes_read < 0)
5330 err = errno;
5331 ntfs_log_trace("Eeek! Failed to read attribute data.
Leaving "
5332 "inconstant metadata. Run chkdsk. "
5333 "Aborting...\n");
5334 errno = err;
5335 return -1;
5336 }
Is it correct, should lines 5329, 5330 and 5334 be removed,
or do lines 5330 to 5334 belong to the if in 5329?
Fabian
From b518b29ce5a7b1de7ad3abd6cf61021f5498f937 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Sun, 31 Jul 2011 22:15:42 +0200 Subject: [PATCH 01/11] Prevent ntfs_upcase_build_default() from returning stack garbage in case of malloc failures --- libntfs-3g/unistr.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c index ffaabe0..5afcc29 100644 --- a/libntfs-3g/unistr.c +++ b/libntfs-3g/unistr.c @@ -1262,7 +1262,7 @@ void ntfs_upcase_table_build(ntfschar *uc, u32 uc_len) u32 ntfs_upcase_build_default(ntfschar **upcase) { - u32 upcase_len; + u32 upcase_len = 0; *upcase = (ntfschar*)ntfs_malloc(UPCASE_LEN*2); if (*upcase) { -- 1.7.6
From f371d0b3858396e6807c0697e6d6e8ddc5eefa8c Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Sun, 31 Jul 2011 22:28:50 +0200 Subject: [PATCH 02/11] In fix_startup(), prevent a memory leak or crashes in case of errors --- ntfsprogs/ntfsfix.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index 0d802e4..addab57 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -765,6 +765,7 @@ static int fix_startup(struct ntfs_device *dev, unsigned long flags) int eo; errno = 0; + full_bs = NULL; res = -1; dev_open = FALSE; if (!dev || !dev->d_ops || !dev->d_name) { @@ -847,7 +848,7 @@ error_exit: } } eo = errno; - free(bs); + free(full_bs); if (vol) { free(vol->upcase); free(vol); -- 1.7.6
From 454b4a419cb8f74ed8f5148fcc515ab5e3dd3d1b Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Sun, 31 Jul 2011 22:48:19 +0200 Subject: [PATCH 03/11] Fix undefined behaviour of ntfs_fuse_read() when called with size=0 --- src/lowntfs-3g.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index aeadb17..6304835 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -1255,8 +1255,10 @@ static void ntfs_fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size, s64 total = 0; s64 max_read; - if (!size) + if (!size) { + res = -ERANGE; goto exit; + } buf = (char*)ntfs_malloc(size); if (!buf) { res = -errno; -- 1.7.6
From ea52749d295cef5424d98a6321a2fca85c756c1e Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Sun, 31 Jul 2011 22:56:54 +0200 Subject: [PATCH 04/11] Add missing braces for an else clause in ntfs_rl_extend() so ntfs_rl_realloc() failures are handled properly --- libntfs-3g/runlist.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/libntfs-3g/runlist.c b/libntfs-3g/runlist.c index 383a80b..75ec31f 100644 --- a/libntfs-3g/runlist.c +++ b/libntfs-3g/runlist.c @@ -136,9 +136,10 @@ runlist_element *ntfs_rl_extend(ntfs_attr *na, runlist_element *rl, if (!newrl) { errno = ENOMEM; rl = (runlist_element*)NULL; - } else + } else { na->rl = newrl; rl = &newrl[irl]; + } } else { ntfs_log_error("Cannot extend unmapped runlist"); errno = EIO; -- 1.7.6
From e431b1dadd17512952d01b5c0aec7a9b698b08e9 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 19:25:18 +0200 Subject: [PATCH 05/11] Remove a pointless variable initialization in upgrade_secur_desc() --- libntfs-3g/security.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index b0bbe6b..0cdfb77 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -1064,7 +1064,6 @@ static int upgrade_secur_desc(ntfs_volume *vol, na = ntfs_attr_open(ni, AT_STANDARD_INFORMATION, AT_UNNAMED, 0); if (na) { - res = 0; /* expand standard information attribute to v3.x */ res = ntfs_attr_truncate(na, (s64)sizeof(STANDARD_INFORMATION)); -- 1.7.6
From 0668184d948df2252e3185bf3a56d04e52bcb71e Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 19:29:33 +0200 Subject: [PATCH 06/11] Remove two dead stores in remove_object_id_index() --- libntfs-3g/object_id.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/object_id.c b/libntfs-3g/object_id.c index 8799ddb..059e882 100644 --- a/libntfs-3g/object_id.c +++ b/libntfs-3g/object_id.c @@ -287,7 +287,6 @@ static int remove_object_id_index(ntfs_attr *na, ntfs_index_context *xo, if (size >= (s64)sizeof(GUID)) { memcpy(&key.object_id, &old_attr->object_id,sizeof(GUID)); - size = sizeof(GUID); if (!ntfs_index_lookup(&key, sizeof(OBJECT_ID_INDEX_KEY), xo)) { entry = (struct OBJECT_ID_INDEX*)xo->entry; @@ -300,7 +299,6 @@ static int remove_object_id_index(ntfs_attr *na, ntfs_index_context *xo, memcpy(&old_attr->domain_id, &entry->data.domain_id, sizeof(GUID)); - size = sizeof(OBJECT_ID_ATTR); if (ntfs_index_rm(xo)) ret = -1; } -- 1.7.6
From 92978f4355ef9f1bb0ca11507e5fb40f0938251d Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 19:49:46 +0200 Subject: [PATCH 07/11] Remove a redundant store in utils_is_metadata() --- ntfsprogs/utils.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index c492758..e3f5447 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -870,7 +870,6 @@ int utils_is_metadata(ntfs_inode *inode) if (__metadata(vol, num) == 1) return 1; } - file = inode->mrec; rec = find_first_attribute(AT_FILE_NAME, inode->mrec); if (!rec) -- 1.7.6
From e12f81f61fd2992e093b6630f9a8b5791a4f516e Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 20:00:44 +0200 Subject: [PATCH 08/11] Remove a write-only variable in main() --- ntfsprogs/ntfscp.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/ntfsprogs/ntfscp.c b/ntfsprogs/ntfscp.c index fe6538e..58a6a09 100644 --- a/ntfsprogs/ntfscp.c +++ b/ntfsprogs/ntfscp.c @@ -393,11 +393,9 @@ int main(int argc, char *argv[]) char *filename; ntfs_inode *dir_ni; ntfs_inode *ni; - int dest_path_len; char *dirname_last_whack; filename = basename(opts.dest_file); - dest_path_len = strlen(opts.dest_file); parent_dirname = strdup(opts.dest_file); if (!parent_dirname) { ntfs_log_perror("strdup() failed"); -- 1.7.6
From b120c42b1daae1608df8e749c7a9226090f45782 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 20:03:33 +0200 Subject: [PATCH 09/11] Remove a write-only variable in ntfs_find_group() --- libntfs-3g/acls.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/acls.c b/libntfs-3g/acls.c index 6328420..b87fc66 100644 --- a/libntfs-3g/acls.c +++ b/libntfs-3g/acls.c @@ -522,9 +522,7 @@ gid_t ntfs_find_group(const struct MAPPING* groupmapping, const SID * gsid) { gid_t gid; const struct MAPPING *p; - int gsidsz; - gsidsz = ntfs_sid_size(gsid); p = groupmapping; while (p && p->xid && !ntfs_same_sid(gsid, p->sid)) p = p->next; -- 1.7.6
From 98cfe233e81064dca3cb46964f641619c041e6a8 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Aug 2011 19:35:01 +0200 Subject: [PATCH 10/11] Remove a pointless store in ntfs_attr_make_resident() --- libntfs-3g/attrib.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index e6f614f..a7a9a3f 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -5348,7 +5348,6 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx) * record is in a transiently corrupted state at this moment in time. */ if (ntfs_cluster_free(vol, na, 0, -1) < 0) { - err = errno; ntfs_log_perror("Eeek! Failed to release allocated clusters"); ntfs_log_trace("Ignoring error and leaving behind wasted " "clusters.\n"); -- 1.7.6
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________ ntfs-3g-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel
