libarchive: Fix WideCharToMultiByte output buffer size
Fix `archive_string_append_from_wcs_in_codepage` to account for the already-used portion of the buffer when computing the size of the remaining buffer for ``WideCharToMultiByte` output.
This commit is contained in:
parent
44b8937b76
commit
f7c54d2049
@ -735,7 +735,8 @@ archive_string_append_from_wcs_in_codepage(struct archive_string *as,
|
||||
else
|
||||
dp = &defchar_used;
|
||||
count = WideCharToMultiByte(to_cp, 0, ws, wslen,
|
||||
as->s + as->length, (int)as->buffer_length-1, NULL, dp);
|
||||
as->s + as->length,
|
||||
(int)as->buffer_length - as->length - 1, NULL, dp);
|
||||
if (count == 0 &&
|
||||
GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
/* Expand the MBS buffer and retry. */
|
||||
|
Loading…
Reference in New Issue
Block a user