summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <vinschen@redhat.com>2022-01-21 03:22:56 +1100
committerDamien Miller <djm@mindrot.org>2022-01-21 09:53:07 +1100
commit68085066b6bad43643b43f5957fcc5fd34782ccd (patch)
treeb5c77fb488575078d7a3667a65349d8745b37356
parent2e5cfed513e84444483baf1d8b31c40072b05103 (diff)
Fix signedness bug in Cygwin code
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>
-rw-r--r--openbsd-compat/bsd-cygwin_util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c
index 54628e26..9ede21d2 100644
--- a/openbsd-compat/bsd-cygwin_util.c
+++ b/openbsd-compat/bsd-cygwin_util.c
@@ -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);