kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

6.9.1: subvolume names are cut off, last character is missing #829

Closed hhoffstaette closed 4 days ago

hhoffstaette commented 6 days ago

With 6.9:

$btrfs subvolume list /mnt/backup
ID 256 gen 22191 top level 5 path hho
ID 257 gen 22195 top level 5 path ragnarok
ID 258 gen 22194 top level 5 path tux

With 6.9.1:

$btrfs subvolume list /mnt/backup                  
ID 256 gen 22191 top level 5 path hh
ID 257 gen 22195 top level 5 path ragnaro
ID 258 gen 22194 top level 5 path tu

Obviously this leads to lots of failures with any automated subvolume/snapshot management.

hhoffstaette commented 6 days ago

Looks like a problem with the recently changed strncpy/string-utils.

kdave commented 6 days ago

Thanks for the report.

--- a/cmds/subvolume-list.c
+++ b/cmds/subvolume-list.c
@@ -547,7 +547,7 @@ static int update_root(struct rb_root *root_lookup,
                        error_msg(ERROR_MSG_MEMORY, NULL);
                        exit(1);
                }
-               strncpy_null(ri->name, name, name_len);
+               strncpy_null(ri->name, name, name_len + 1);
        }
        if (ref_tree)
                ri->ref_tree = ref_tree;
@@ -618,7 +618,7 @@ static int add_root(struct rb_root *root_lookup,
                        error_msg(ERROR_MSG_MEMORY, NULL);
                        exit(1);
                }
-               strncpy_null(ri->name, name, name_len);
+               strncpy_null(ri->name, name, name_len + 1);
        }
        if (ref_tree)
                ri->ref_tree = ref_tree;

This fixes the subvolumes, I haven't spotted other problems but will do another pass to be sure.

kdave commented 4 days ago

Released in 6.9.2.