1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-01 19:20:13 -05:00

request_file: fix wchar_t buffer length.

[SGT: the helper function do_filereq_w expects its filename size to be
in characters, not bytes, because it's used both as an index into the
wchar_t buffer and also as nMaxFile in the OPENFILENAMEW structure
which is also documented as measured in characters. So at the call
site it should be measured via lenof rather than sizeof. This patch
has done the same with the char version, which makes no functional
difference but keeps the code more consistent.]
This commit is contained in:
SATO Kentaro 2025-01-19 22:42:49 +09:00 committed by Simon Tatham
parent ec158a2e19
commit 9ab416e018

View File

@ -235,13 +235,13 @@ Filename *request_file(
char namebuf[MAX_PATH];
if (do_filereq_a(
hwnd, title, initial, dir, save, filter,
NULL, namebuf, sizeof(namebuf)))
NULL, namebuf, lenof(namebuf)))
filename = filename_from_str(namebuf);
} else {
wchar_t namebuf[MAX_PATH];
if (do_filereq_w(
hwnd, title, initial, dir, save, filter,
NULL, namebuf, sizeof(namebuf)))
NULL, namebuf, lenof(namebuf)))
filename = filename_from_wstr(namebuf);
}
@ -349,14 +349,14 @@ struct request_multi_file_return *request_multi_file(
char namebuf[MAX_PATH * MULTI_FACTOR];
if (do_filereq_a(
hwnd, title, initial, dir, save, filter,
&first_filename_offset, namebuf, sizeof(namebuf)))
&first_filename_offset, namebuf, lenof(namebuf)))
rmf = request_multi_file_populate_a(
namebuf, first_filename_offset);
} else {
wchar_t namebuf[MAX_PATH * MULTI_FACTOR];
if (do_filereq_w(
hwnd, title, initial, dir, save, filter,
&first_filename_offset, namebuf, sizeof(namebuf)))
&first_filename_offset, namebuf, lenof(namebuf)))
rmf = request_multi_file_populate_w(
namebuf, first_filename_offset);
}