http://bugs.gentoo.org/100633 =================================================================== RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/unistr.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- linux-ntfs/ntfsprogs/libntfs/unistr.c 2005/07/06 22:47:18 1.20 +++ linux-ntfs/ntfsprogs/libntfs/unistr.c 2005/07/28 21:20:23 1.21 @@ -467,7 +467,7 @@ 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 @@ 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 @@ } /* 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;