Check for snprintf truncation on W32 * src/main.c (find_and_set_default_shell) [MK_OS_W32]: Do not use a buffer that snprintf truncated.
diff --git a/src/main.c b/src/main.c index e8d1938..78084d0 100644 --- a/src/main.c +++ b/src/main.c
@@ -1080,12 +1080,15 @@ while (ep && *ep) { + int sh_pathlen; PATH_VAR (sh_path); *ep = '\0'; - snprintf (sh_path, GET_PATH_MAX, "%s/%s", p, search_token); - if (_access (sh_path, 0) == 0) + sh_pathlen = snprintf (sh_path, GET_PATH_MAX, "%s/%s", + p, search_token); + if (0 <= sh_pathlen && sh_pathlen < GET_PATH_MAX + && _access (sh_path, 0) == 0) { default_shell = xstrdup (w32ify (sh_path, 0)); sh_found = 1; @@ -1106,9 +1109,13 @@ /* be sure to check last element of Path */ if (p && *p) { + int sh_pathlen; + PATH_VAR (sh_path); - snprintf (sh_path, GET_PATH_MAX, "%s/%s", p, search_token); - if (_access (sh_path, 0) == 0) + sh_pathlen = snprintf (sh_path, GET_PATH_MAX, "%s/%s", + p, search_token); + if (0 <= sh_pathlen && sh_pathlen < GET_PATH_MAX + && _access (sh_path, 0) == 0) { default_shell = xstrdup (w32ify (sh_path, 0)); sh_found = 1;