From fb433d4ad3dbbba3fc8f10e136c154d23c413947 Mon Sep 17 00:00:00 2001 From: cha0smaster Date: Thu, 28 Jul 2005 21:20:23 +0000 Subject: [PATCH] Fix unistr.c::ntfs_mbstoucs on systems with utf8 locale. --- ChangeLog | 1 + libntfs/unistr.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 105dedea..9ee46dc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ xx/xx/xxxx - 1.12.0-WIP extent. (Szaka) - ntfscp: fix attribute name parsing bug introduced in 1.10.0. (Yura) - ntfsinfo: dump more information for indexes. (Yura) + - Fix unistr.c::ntfs_mbstoucs on systems with utf8 locale. (Yura) 20/07/2005 - 1.11.1 - Fix several ntfsmount bugs. diff --git a/libntfs/unistr.c b/libntfs/unistr.c index e0c144b8..afa206b0 100644 --- a/libntfs/unistr.c +++ b/libntfs/unistr.c @@ -467,7 +467,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs, int outs_len) ntfschar *ucs; const char *s; wchar_t wc; - int i, o, cnt, ins_len, ucs_len; + int i, o, cnt, ins_len, ucs_len, ins_size; #ifdef HAVE_MBSINIT mbstate_t mbstate; #endif @@ -482,6 +482,8 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs, int outs_len) errno = ENAMETOOLONG; return -1; } + /* Determine the size of the multi-byte string in bytes. */ + ins_size = strlen(ins); /* Determine the length of the multi-byte string. */ s = ins; #if defined(HAVE_MBSINIT) @@ -543,9 +545,9 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs, int outs_len) } /* Convert the multibyte character to a wide character. */ #ifdef HAVE_MBSINIT - cnt = mbrtowc(&wc, ins + i, ins_len - i, &mbstate); + cnt = mbrtowc(&wc, ins + i, ins_size - i, &mbstate); #else - cnt = mbtowc(&wc, ins + i, ins_len - i); + cnt = mbtowc(&wc, ins + i, ins_size - i); #endif if (!cnt) break;