diff mbox

Minor coverity defect fix - CID 1125928 In set_file_xattrs: Dereference of an explicit null value

Message ID 1479258473-30053-1-git-send-email-harinath922@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Harinath Nampally Nov. 16, 2016, 1:07 a.m. UTC
---
 cmds-restore.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Sterba Nov. 30, 2016, 3:21 p.m. UTC | #1
Hi,

this patch lacks basic formatting requirements, this has been
extensively documented eg. here https://btrfs.wiki.kernel.org/index.php/Developer's_FAQ .

Besides the formalities, I'm missing what's the change rationale. It
deals with a strange case when the xattr name length is 0, which is
unexpected and should not be handled silently. Next I'm not sure if
bailing out of the function is right, there are more items to process.
Best if we could skip the damaged ones but still continue.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-restore.c b/cmds-restore.c
index a8c67a5..6c2ea8a 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -509,6 +509,9 @@  static int set_file_xattrs(struct btrfs_root *root, u64 inode,
 
 		while (cur < total_len) {
 			len = btrfs_dir_name_len(leaf, di);
+                        if (len == 0) {
+                                goto out;
+                        }
 			if (len > name_len) {
 				free(name);
 				name = (char *) malloc(len + 1);