f2fs: avoid garbage lenghs in dentries
[deliverable/linux.git] / fs / f2fs / dir.c
index 8950fc3cc2f7578520bfb340e80c7269b3dd8064..ca41b2a778492fb3c4c4ccefd22dc794d6ce2829 100644 (file)
@@ -511,8 +511,12 @@ void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d,
        memcpy(d->filename[bit_pos], name->name, name->len);
        de->ino = cpu_to_le32(ino);
        set_de_type(de, mode);
-       for (i = 0; i < slots; i++)
+       for (i = 0; i < slots; i++) {
                test_and_set_bit_le(bit_pos + i, (void *)d->bitmap);
+               /* avoid wrong garbage data for readdir */
+               if (i)
+                       (de + i)->name_len = 0;
+       }
 }
 
 /*
@@ -792,6 +796,12 @@ bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        break;
 
                de = &d->dentry[bit_pos];
+               if (de->name_len == 0) {
+                       bit_pos++;
+                       ctx->pos = start_pos + bit_pos;
+                       continue;
+               }
+
                if (de->file_type < F2FS_FT_MAX)
                        d_type = f2fs_filetype_table[de->file_type];
                else
This page took 0.024786 seconds and 5 git commands to generate.