summaryrefslogtreecommitdiff
path: root/Utilities
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:13:29 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:13:29 +0900
commit0093b6749408dc1fa6c0578865555750171940a9 (patch)
tree150446d9eff60021385a36d07f0a92c9d3c47851 /Utilities
parentd3ab5eb53d4ef4c187524c2804aa6e0a6406da89 (diff)
downloadcmake-0093b6749408dc1fa6c0578865555750171940a9.tar.gz
cmake-0093b6749408dc1fa6c0578865555750171940a9.tar.bz2
cmake-0093b6749408dc1fa6c0578865555750171940a9.zip
Imported Upstream version 3.12.3upstream/3.12.3
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h3
-rw-r--r--Utilities/cmlibuv/src/unix/fs.c47
2 files changed, 41 insertions, 9 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
index 59f95b80a..921249bb9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
@@ -28,7 +28,8 @@
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
#include <stdlib.h> /* malloc, free */
#include <string.h> /* memset */
static inline HMAC_CTX *HMAC_CTX_new(void)
diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c
index 4545168f2..a6cc6dbd1 100644
--- a/Utilities/cmlibuv/src/unix/fs.c
+++ b/Utilities/cmlibuv/src/unix/fs.c
@@ -425,19 +425,22 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
return n;
}
+#if defined(_POSIX_PATH_MAX)
+# define UV__FS_PATH_MAX _POSIX_PATH_MAX
+#elif defined(PATH_MAX)
+# define UV__FS_PATH_MAX PATH_MAX
+#else
+# define UV__FS_PATH_MAX_FALLBACK 8192
+# define UV__FS_PATH_MAX UV__FS_PATH_MAX_FALLBACK
+#endif
static ssize_t uv__fs_pathmax_size(const char* path) {
ssize_t pathmax;
pathmax = pathconf(path, _PC_PATH_MAX);
- if (pathmax == -1) {
-#if defined(PATH_MAX)
- return PATH_MAX;
-#else
-#error "PATH_MAX undefined in the current platform"
-#endif
- }
+ if (pathmax == -1)
+ pathmax = UV__FS_PATH_MAX;
return pathmax;
}
@@ -446,7 +449,28 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
ssize_t len;
char* buf;
+#if defined(UV__FS_PATH_MAX_FALLBACK)
+ /* We may not have a real PATH_MAX. Read size of link. */
+ struct stat st;
+ int ret;
+ ret = lstat(req->path, &st);
+ if (ret != 0)
+ return -1;
+ if (!S_ISLNK(st.st_mode)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ len = st.st_size;
+
+ /* According to readlink(2) lstat can report st_size == 0
+ for some symlinks, such as those in /proc or /sys. */
+ if (len == 0)
+ len = uv__fs_pathmax_size(req->path);
+#else
len = uv__fs_pathmax_size(req->path);
+#endif
+
buf = uv__malloc(len + 1);
if (buf == NULL) {
@@ -473,9 +497,15 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
}
static ssize_t uv__fs_realpath(uv_fs_t* req) {
- ssize_t len;
char* buf;
+#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
+ buf = realpath(req->path, NULL);
+ if (buf == NULL)
+ return -1;
+#else
+ ssize_t len;
+
len = uv__fs_pathmax_size(req->path);
buf = uv__malloc(len + 1);
@@ -488,6 +518,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) {
uv__free(buf);
return -1;
}
+#endif
req->ptr = buf;