mirror of
https://github.com/fltk/fltk.git
synced 2026-05-21 14:31:40 +08:00
Solve issue #206 warning.
This commit is contained in:
@@ -524,10 +524,14 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() {
|
|||||||
char pathname[FNFC_MAX_PATH];
|
char pathname[FNFC_MAX_PATH];
|
||||||
for ( const WCHAR *s = dirname + dirlen + 1;
|
for ( const WCHAR *s = dirname + dirlen + 1;
|
||||||
*s; s += (wcslen(s)+1)) {
|
*s; s += (wcslen(s)+1)) {
|
||||||
strncpy(pathname, wchartoutf8(dirname), FNFC_MAX_PATH);
|
// ISSUE #206 -- beware strncpy() vs. strncat():
|
||||||
strncat(pathname, "\\", FNFC_MAX_PATH);
|
// > strncpy() doesn't guarantee null termination but strncat() does.
|
||||||
strncat(pathname, wchartoutf8(s), FNFC_MAX_PATH);
|
// > strncat() can write to n+1, whereas strncpy() only writes to n.
|
||||||
pathname[FNFC_MAX_PATH-1] = 0;
|
// fl_snprintf() can't be used here b/c wchartoutf8() returns a static str.
|
||||||
|
//
|
||||||
|
strncpy(pathname, wchartoutf8(dirname), FNFC_MAX_PATH); pathname[FNFC_MAX_PATH-1] = 0;
|
||||||
|
strncat(pathname, "\\", FNFC_MAX_PATH-1);
|
||||||
|
strncat(pathname, wchartoutf8(s), FNFC_MAX_PATH-1);
|
||||||
add_pathname(pathname);
|
add_pathname(pathname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user