]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Fix signedness bug in Cygwin code
authorCorinna Vinschen <vinschen@redhat.com>
Thu, 20 Jan 2022 16:22:56 +0000 (03:22 +1100)
committerDamien Miller <djm@mindrot.org>
Thu, 20 Jan 2022 22:53:07 +0000 (09:53 +1100)
The Cygwin-specific pattern match code has a bug.  It checks
the size_t value returned by mbstowcs for being < 0.  The right
thing to do is to check against (size_t) -1.  Fix that.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
openbsd-compat/bsd-cygwin_util.c

index 54628e2607b4cd4e3005e6afd35b7f106f07b083..9ede21d243a210658f0331535f0f6dce602ca2cc 100644 (file)
@@ -194,11 +194,11 @@ _match_pattern(const char *s, const char *pattern)
        size_t len;
        int ret;
 
-       if ((len = mbstowcs(NULL, s, 0)) < 0)
+       if ((len = mbstowcs(NULL, s, 0)) == (size_t) -1)
                return 0;
        ws = (wchar_t *) xcalloc(len + 1, sizeof (wchar_t));
        mbstowcs(ws, s, len + 1);
-       if ((len = mbstowcs(NULL, pattern, 0)) < 0)
+       if ((len = mbstowcs(NULL, pattern, 0)) == (size_t) -1)
                return 0;
        wpattern = (wchar_t *) xcalloc(len + 1, sizeof (wchar_t));
        mbstowcs(wpattern, pattern, len + 1);