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

Message ID 1479258473-30053-1-git-send-email-harinath922@gmail.com
State New
Headers show

Commit Message

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


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

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

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) {
 				name = (char *) malloc(len + 1);