diff --git a/src/tar.cpp b/src/tar.cpp index 11e4cb6..8ffdc64 100644 --- a/src/tar.cpp +++ b/src/tar.cpp @@ -509,9 +509,10 @@ int pax_encode::create_header(HANDLE hFile, fileinfo * fi, LPCWSTR fullFilename, m_fullname.wstr[--ffn_len] = 0; } LPSTR utf8name = m_utf8name.str + 2; - int aLen = WideCharToMultiByte(CP_UTF8, 0, m_fullname.wstr, -1, utf8name, (int)m_utf8name.size - 8, NULL, NULL); - FIN_IF(aLen <= 1, 0x1502700); - size_t ufn_len = strlen(utf8name); + int aLen = WideCharToMultiByte(CP_UTF8, 0, m_fullname.wstr, (int)ffn_len, utf8name, (int)m_utf8name.size - 8, NULL, NULL); + FIN_IF(aLen <= 0, 0x1502700); + FIN_IF((size_t)aLen >= m_utf8name.size - 8, 0x1502800); + size_t ufn_len = aLen; utf8name[ufn_len] = 0; size_t k = INT_MAX; diff --git a/src/wcx_cache.cpp b/src/wcx_cache.cpp index 5bc2a39..dffae10 100644 --- a/src/wcx_cache.cpp +++ b/src/wcx_cache.cpp @@ -311,6 +311,7 @@ int cache::add_pax_info(tar::pax_decode & pax, UINT64 file_pos, UINT64 frame_siz break; int x = MultiByteToWideChar(CP_UTF8, 0, name, (int)nlen, m_add_name.data(), (int)m_add_name.capacity() - 32); FIN_IF(x <= 0, 0x45013400 | E_EOPEN); + m_add_name.data()[x] = 0; m_add_name.fix_length(); LPWSTR ws = m_add_name.data(); do { @@ -483,7 +484,7 @@ int cache::scan_paxlz4_file(HANDLE hFile) size_t plen = frame.data_size; DWORD calc_hash = XXH32(pd, plen, 0); DWORD read_hash = *(PDWORD)(pd + plen); - LOGi("pos = 0x%X hash = %08X cacl = %08X ", (DWORD)pos.QuadPart - 4, read_hash, calc_hash); + //LOGi("pos = 0x%X hash = %08X calc = %08X ", (DWORD)pos.QuadPart - 4, read_hash, calc_hash); FIN_IF(read_hash != calc_hash, 0x44013700 | E_EOPEN); if (frame.is_compressed) {