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