|
Kmods SIG |
8b815c |
From 2c69078851b3d7495eb191158d0bcb9c91a6d148 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
8b815c |
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
8b815c |
Date: Mon, 4 Oct 2021 18:22:45 +0300
|
|
Kmods SIG |
8b815c |
Subject: [Backport 2c69078851b3] src: Rework ntfs_utf16_to_nls
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
Now ntfs_utf16_to_nls takes length as one of arguments.
|
|
Kmods SIG |
8b815c |
If length of symlink > 255, then we tried to convert
|
|
Kmods SIG |
8b815c |
length of symlink +- some random number.
|
|
Kmods SIG |
8b815c |
Now 255 symbols limit was removed.
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
8b815c |
---
|
|
Kmods SIG |
8b815c |
src/dir.c | 19 ++++++++-----------
|
|
Kmods SIG |
8b815c |
src/ntfs_fs.h | 2 +-
|
|
Kmods SIG |
8b815c |
2 files changed, 9 insertions(+), 12 deletions(-)
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
diff --git a/src/dir.c b/src/dir.c
|
|
Kmods SIG |
8b815c |
index 785e72d4392e152ef6833721e887ed9ef056094b..fb438d6040409838389ba7454645034ab2fa7a08 100644
|
|
Kmods SIG |
8b815c |
--- a/src/dir.c
|
|
Kmods SIG |
8b815c |
+++ b/src/dir.c
|
|
Kmods SIG |
8b815c |
@@ -15,11 +15,10 @@
|
|
Kmods SIG |
8b815c |
#include "ntfs_fs.h"
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
/* Convert little endian UTF-16 to NLS string. */
|
|
Kmods SIG |
8b815c |
-int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
|
|
Kmods SIG |
8b815c |
+int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
|
|
Kmods SIG |
8b815c |
u8 *buf, int buf_len)
|
|
Kmods SIG |
8b815c |
{
|
|
Kmods SIG |
8b815c |
- int ret, uni_len, warn;
|
|
Kmods SIG |
8b815c |
- const __le16 *ip;
|
|
Kmods SIG |
8b815c |
+ int ret, warn;
|
|
Kmods SIG |
8b815c |
u8 *op;
|
|
Kmods SIG |
8b815c |
struct nls_table *nls = sbi->options->nls;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
@@ -27,18 +26,16 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
if (!nls) {
|
|
Kmods SIG |
8b815c |
/* UTF-16 -> UTF-8 */
|
|
Kmods SIG |
8b815c |
- ret = utf16s_to_utf8s((wchar_t *)uni->name, uni->len,
|
|
Kmods SIG |
8b815c |
- UTF16_LITTLE_ENDIAN, buf, buf_len);
|
|
Kmods SIG |
8b815c |
+ ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf,
|
|
Kmods SIG |
8b815c |
+ buf_len);
|
|
Kmods SIG |
8b815c |
buf[ret] = '\0';
|
|
Kmods SIG |
8b815c |
return ret;
|
|
Kmods SIG |
8b815c |
}
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
- ip = uni->name;
|
|
Kmods SIG |
8b815c |
op = buf;
|
|
Kmods SIG |
8b815c |
- uni_len = uni->len;
|
|
Kmods SIG |
8b815c |
warn = 0;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
- while (uni_len--) {
|
|
Kmods SIG |
8b815c |
+ while (len--) {
|
|
Kmods SIG |
8b815c |
u16 ec;
|
|
Kmods SIG |
8b815c |
int charlen;
|
|
Kmods SIG |
8b815c |
char dump[5];
|
|
Kmods SIG |
8b815c |
@@ -49,7 +46,7 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
|
|
Kmods SIG |
8b815c |
break;
|
|
Kmods SIG |
8b815c |
}
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
- ec = le16_to_cpu(*ip++);
|
|
Kmods SIG |
8b815c |
+ ec = le16_to_cpu(*name++);
|
|
Kmods SIG |
8b815c |
charlen = nls->uni2char(ec, op, buf_len);
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
if (charlen > 0) {
|
|
Kmods SIG |
8b815c |
@@ -304,8 +301,8 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
|
|
Kmods SIG |
8b815c |
return 0;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
- name_len = ntfs_utf16_to_nls(sbi, (struct le_str *)&fname->name_len,
|
|
Kmods SIG |
8b815c |
- name, PATH_MAX);
|
|
Kmods SIG |
8b815c |
+ name_len = ntfs_utf16_to_nls(sbi, fname->name, fname->name_len, name,
|
|
Kmods SIG |
8b815c |
+ PATH_MAX);
|
|
Kmods SIG |
8b815c |
if (name_len <= 0) {
|
|
Kmods SIG |
8b815c |
ntfs_warn(sbi->sb, "failed to convert name for inode %lx.",
|
|
Kmods SIG |
8b815c |
ino);
|
|
Kmods SIG |
8b815c |
diff --git a/src/ntfs_fs.h b/src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
index 38b7c1a9dc5209badca36b6a7cb8a2b38845b2e9..9277b552f2578ee8e94784afe9772614b02748a0 100644
|
|
Kmods SIG |
8b815c |
--- a/src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
+++ b/src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
@@ -475,7 +475,7 @@ bool are_bits_set(const ulong *map, size_t bit, size_t nbits);
|
|
Kmods SIG |
8b815c |
size_t get_set_bits_ex(const ulong *map, size_t bit, size_t nbits);
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
/* Globals from dir.c */
|
|
Kmods SIG |
8b815c |
-int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
|
|
Kmods SIG |
8b815c |
+int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
|
|
Kmods SIG |
8b815c |
u8 *buf, int buf_len);
|
|
Kmods SIG |
8b815c |
int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
|
|
Kmods SIG |
8b815c |
struct cpu_str *uni, u32 max_ulen,
|
|
Kmods SIG |
8b815c |
--
|
|
Kmods SIG |
8b815c |
2.31.1
|
|
Kmods SIG |
8b815c |
|