OSDN Git Service

ntfslabel.c: Fix incorrect label buffer being NULL-terminated.
authorErik Larsson <mechie@users.sourceforge.net>
Mon, 8 Feb 2016 17:32:24 +0000 (18:32 +0100)
committerErik Larsson <mechie@users.sourceforge.net>
Mon, 8 Feb 2016 17:32:24 +0000 (18:32 +0100)
The UTF-16LE label buffer containing the result of mbs2ucs is the one
that should be NULL-terminated when the label is longer than permitted.
Not the input buffer, which is a function parameter assumed to be
NULL-terminated anyway.

ntfsprogs/ntfslabel.c

index 77a34f0..e2d36c8 100644 (file)
@@ -389,7 +389,7 @@ static int change_label(ntfs_volume *vol, char *label)
                                (unsigned)(label_len -
                                (0x100 / sizeof(ntfschar))));
                label_len = 0x100 / sizeof(ntfschar);
-               label[label_len] = 0;
+               new_label[label_len] = const_cpu_to_le16(0);
        }
 
        if(!opts.noaction)