diff options
author | Brad King <brad.king@kitware.com> | 2020-02-06 19:28:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-02-06 20:04:47 (GMT) |
commit | f7c54d2049b28414be75d1792542722e82b7ed64 (patch) | |
tree | 0f3096aff75aab4f935a025cd8bfaa68fd145f42 | |
parent | 44b8937b7614560d9e88d25456c8394b4b209d51 (diff) | |
download | CMake-f7c54d2049b28414be75d1792542722e82b7ed64.zip CMake-f7c54d2049b28414be75d1792542722e82b7ed64.tar.gz CMake-f7c54d2049b28414be75d1792542722e82b7ed64.tar.bz2 |
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.
-rw-r--r-- | Utilities/cmlibarchive/libarchive/archive_string.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c index 554533e..9df76ff 100644 --- a/Utilities/cmlibarchive/libarchive/archive_string.c +++ b/Utilities/cmlibarchive/libarchive/archive_string.c @@ -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. */ |