diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c index 764e297a..55ce1e8f 100644 --- a/libntfs-3g/unistr.c +++ b/libntfs-3g/unistr.c @@ -1085,7 +1085,7 @@ void ntfs_ucsfree(ntfschar *ucs) BOOL ntfs_forbidden_chars(const ntfschar *name, int len) { - BOOL forbidden = FALSE; + BOOL forbidden; int ch; int i; u32 mainset = (1L << ('\"' - 0x20)) @@ -1096,9 +1096,12 @@ BOOL ntfs_forbidden_chars(const ntfschar *name, int len) | (1L << ('>' - 0x20)) | (1L << ('?' - 0x20)); + forbidden = (len == 0) + || (le16_to_cpu(name[0]) == ' ') + || (le16_to_cpu(name[len-1]) == ' '); for (i=0; i