On Fri, Feb 22, 2019 at 10:29:46AM +0100, Corinna Vinschen wrote: > On Feb 22 16:02, Darren Tucker wrote: [...] > > How's this? If we push the match_usergroup_pattern_list() function up > > to OpenBSD it should mean most future diffs will apply cleanly. > > I like this a lot. > > But that also means the cygwin_match_pattern_list function will be > called only for user and group names, and that in turn means the cygwin > function is always called for case-insensitive operation. > > How's this? It's just tweaking your patch a bit, simplifying the Cygwin > code. Looks good, I've committed it. One final tweak: replace alloca with xcalloc since it checks for integer overflow, will fail instead of blowing the stack on large allocs and is likely at a less well-known location. Also include stdlib.h for the prototype for free(). diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 1e4cdc92..54628e26 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c @@ -37,6 +37,7 @@ #include <string.h> #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include <wchar.h> #include <wctype.h> @@ -191,16 +192,20 @@ _match_pattern(const char *s, const char *pattern) wchar_t *ws; wchar_t *wpattern; size_t len; + int ret; if ((len = mbstowcs(NULL, s, 0)) < 0) return 0; - ws = (wchar_t *) alloca((len + 1) * sizeof (wchar_t)); + ws = (wchar_t *) xcalloc(len + 1, sizeof (wchar_t)); mbstowcs(ws, s, len + 1); if ((len = mbstowcs(NULL, pattern, 0)) < 0) return 0; - wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t)); + wpattern = (wchar_t *) xcalloc(len + 1, sizeof (wchar_t)); mbstowcs(wpattern, pattern, len + 1); - return __match_pattern (ws, wpattern); + ret = __match_pattern (ws, wpattern); + free(ws); + free(wpattern); + return ret; } /* -- Darren Tucker (dtucker at dtucker.net) GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA (new) Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement. _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@xxxxxxxxxxx https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev