diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-10-22 22:53:29 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-10-22 22:53:29 +0200 |
commit | bbeef8ef3fc017dc7a1e042c3b0e2456dcc8b51f (patch) | |
tree | 964759333522af5d33602a46e0515b21fa6cc7f3 /winsup/utils | |
parent | 7909b528e57b2f2a77f3afde0f73e0b93ebc345a (diff) | |
download | newlib-bbeef8ef3fc017dc7a1e042c3b0e2456dcc8b51f.zip newlib-bbeef8ef3fc017dc7a1e042c3b0e2456dcc8b51f.tar.gz newlib-bbeef8ef3fc017dc7a1e042c3b0e2456dcc8b51f.tar.bz2 |
cygcheck: Fix broken test for invalid wcstombs conversion reading symlinks
Fixes Coverity CID 66905
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils')
-rw-r--r-- | winsup/utils/path.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index 336408d..a76cf76 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -220,10 +220,10 @@ readlink (HANDLE fh, char *path, int maxlen) } if (*(PWCHAR) cp == 0xfeff) /* BOM */ { - len = wcstombs (NULL, (wchar_t *) (cp + 2), 0); - if (len == (size_t) -1 || len + 1 > maxlen) + size_t wlen = wcstombs (NULL, (wchar_t *) (cp + 2), 0); + if (wlen == (size_t) -1 || wlen + 1 > maxlen) return false; - wcstombs (path, (wchar_t *) (cp + 2), len + 1); + wcstombs (path, (wchar_t *) (cp + 2), wlen + 1); } else if (len + 1 > maxlen) return false; @@ -238,10 +238,10 @@ readlink (HANDLE fh, char *path, int maxlen) cp = buf + strlen (SYMLINK_COOKIE); if (*(PWCHAR) cp == 0xfeff) /* BOM */ { - len = wcstombs (NULL, (wchar_t *) (cp + 2), 0); - if (len == (size_t) -1 || len + 1 > maxlen) + size_t wlen = wcstombs (NULL, (wchar_t *) (cp + 2), 0); + if (wlen == (size_t) -1 || wlen + 1 > maxlen) return false; - wcstombs (path, (wchar_t *) (cp + 2), len + 1); + wcstombs (path, (wchar_t *) (cp + 2), wlen + 1); } else if (fi.nFileSizeLow - strlen (SYMLINK_COOKIE) > (unsigned) maxlen) return false; |