Skip to content

Commit 155d1d5

Browse files
cjihrigMylesBorins
authored andcommitted
deps: upgrade to libuv 1.24.1
PR-URL: #25078 Fixes: #24521 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 4f28da8 commit 155d1d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+421
-127
lines changed

deps/uv/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Makefile.in
4242
/android-toolchain
4343

4444
/out/
45-
/build/gyp
45+
/build/
4646

4747
/test/.libs/
4848
/test/run-tests

deps/uv/AUTHORS

+6
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,9 @@ hitesh <sainihitesh.scientist@gmail.com>
356356
Svante Signell <svante.signell@gmail.com>
357357
Samuel Thibault <sthibault@debian.org>
358358
Jeremy Studer <studerj1.mail@gmail.com>
359+
damon-kwok <563066990@qq.com>
360+
Damon Kwok <MedusaIDE@outlook.com>
361+
Ashe Connor <ashe@kivikakk.ee>
362+
Rick <lcw0622@163.com>
363+
Ivan Krylov <krylov.r00t@gmail.com>
364+
Michael Meier <michael.meier@leica-geosystems.com>

deps/uv/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(uv_sources
1515
src/fs-poll.c
1616
src/idna.c
1717
src/inet.c
18+
src/strscpy.c
1819
src/threadpool.c
1920
src/timer.c
2021
src/uv-common.c
@@ -116,6 +117,7 @@ set(uv_test_sources
116117
test/test-socket-buffer-size.c
117118
test/test-spawn.c
118119
test/test-stdio-over-pipes.c
120+
test/test-strscpy.c
119121
test/test-tcp-alloc-cb-fail.c
120122
test/test-tcp-bind-error.c
121123
test/test-tcp-bind6-error.c
@@ -208,7 +210,11 @@ if(WIN32)
208210
list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
209211
else()
210212
list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
211-
list(APPEND uv_libraries pthread)
213+
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
214+
# Android has pthread as part of its c library, not as a separate
215+
# libpthread.so.
216+
list(APPEND uv_libraries pthread)
217+
endif()
212218
list(APPEND uv_sources
213219
src/unix/async.c
214220
src/unix/core.c

deps/uv/ChangeLog

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
2018.12.17, Version 1.24.1 (Stable), 274f2bd3b70847cadd9a3965577a87e666ab9ac3
2+
3+
Changes since version 1.24.0:
4+
5+
* test: fix platform_output test on cygwin (damon-kwok)
6+
7+
* gitignore: ignore build/ directory (Damon Kwok)
8+
9+
* unix: zero epoll_event before use (Ashe Connor)
10+
11+
* darwin: use runtime check for file cloning (Ben Noordhuis)
12+
13+
* doc: replace deprecated build command on macOS (Rick)
14+
15+
* warnings: fix code that emits compiler warnings (Jameson Nash)
16+
17+
* doc: clarify expected memory management strategy (Ivan Krylov)
18+
19+
* test: add uv_inet_ntop(AF_INET) coverage (Ben Noordhuis)
20+
21+
* unix: harden string copying, introduce strscpy() (Ben Noordhuis)
22+
23+
* linux: get rid of strncpy() call (Ben Noordhuis)
24+
25+
* aix: get rid of strcat() calls (Ben Noordhuis)
26+
27+
* aix: fix data race in uv_fs_event_start() (Ben Noordhuis)
28+
29+
* win: fs: fix `FILE_FLAG_NO_BUFFERING` for writes (Joran Dirk Greef)
30+
31+
* build: don't link against -lpthread on Android (Michael Meier)
32+
33+
134
2018.11.14, Version 1.24.0 (Stable), 2d427ee0083d1baf995df4ebf79a3f8890e9a3e1
235

336
Changes since version 1.23.2:

deps/uv/Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ libuv_la_SOURCES = src/fs-poll.c \
3232
src/idna.c \
3333
src/inet.c \
3434
src/queue.h \
35+
src/strscpy.c \
36+
src/strscpy.h \
3537
src/threadpool.c \
3638
src/timer.c \
3739
src/uv-data-getter-setters.c \
@@ -241,6 +243,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
241243
test/test-socket-buffer-size.c \
242244
test/test-spawn.c \
243245
test/test-stdio-over-pipes.c \
246+
test/test-strscpy.c \
244247
test/test-tcp-alloc-cb-fail.c \
245248
test/test-tcp-bind-error.c \
246249
test/test-tcp-bind6-error.c \

deps/uv/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ Run:
262262

263263
```bash
264264
$ ./gyp_uv.py -f xcode
265-
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
266-
-configuration Release -target All
265+
$ xcodebuild -ARCHS="x86_64" -project out/uv.xcodeproj -configuration Release -alltargets
267266
```
268267

269268
Using Homebrew:

deps/uv/configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
AC_PREREQ(2.57)
16-
AC_INIT([libuv], [1.24.0], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.24.1], [https://github.com/libuv/libuv/issues])
1717
AC_CONFIG_MACRO_DIR([m4])
1818
m4_include([m4/libuv-extra-automake-flags.m4])
1919
m4_include([m4/as_case.m4])

deps/uv/docs/src/handle.rst

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ API
140140
141141
Request handle to be closed. `close_cb` will be called asynchronously after
142142
this call. This MUST be called on each handle before memory is released.
143+
Moreover, the memory can only be released in `close_cb` or after it has
144+
returned.
143145
144146
Handles that wrap file descriptors are closed immediately but
145147
`close_cb` will still be deferred to the next iteration of the event loop.

deps/uv/include/uv/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define UV_VERSION_MAJOR 1
3434
#define UV_VERSION_MINOR 24
35-
#define UV_VERSION_PATCH 0
35+
#define UV_VERSION_PATCH 1
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

deps/uv/include/uv/win.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
2727
typedef intptr_t ssize_t;
28+
# define SSIZE_MAX INTPTR_MAX
2829
# define _SSIZE_T_
2930
# define _SSIZE_T_DEFINED
3031
#endif

deps/uv/src/inet.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
5959
if (l <= 0 || (size_t) l >= size) {
6060
return UV_ENOSPC;
6161
}
62-
strncpy(dst, tmp, size);
63-
dst[size - 1] = '\0';
62+
uv__strscpy(dst, tmp, size);
6463
return 0;
6564
}
6665

@@ -142,14 +141,8 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
142141
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
143142
*tp++ = ':';
144143
*tp++ = '\0';
145-
146-
/*
147-
* Check for overflow, copy, and we're done.
148-
*/
149-
if ((size_t)(tp - tmp) > size) {
144+
if (UV_E2BIG == uv__strscpy(dst, tmp, size))
150145
return UV_ENOSPC;
151-
}
152-
strcpy(dst, tmp);
153146
return 0;
154147
}
155148

deps/uv/src/strscpy.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "strscpy.h"
2+
#include <limits.h> /* SSIZE_MAX */
3+
4+
ssize_t uv__strscpy(char* d, const char* s, size_t n) {
5+
size_t i;
6+
7+
for (i = 0; i < n; i++)
8+
if ('\0' == (d[i] = s[i]))
9+
return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;
10+
11+
if (i == 0)
12+
return 0;
13+
14+
d[--i] = '\0';
15+
16+
return UV_E2BIG;
17+
}

deps/uv/src/strscpy.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef UV_STRSCPY_H_
2+
#define UV_STRSCPY_H_
3+
4+
/* Include uv.h for its definitions of size_t and ssize_t.
5+
* size_t can be obtained directly from <stddef.h> but ssize_t requires
6+
* some hoop jumping on Windows that I didn't want to duplicate here.
7+
*/
8+
#include "uv.h"
9+
10+
/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates
11+
* the result, except when |n==0|. Returns the number of bytes copied
12+
* or UV_E2BIG if |d| is too small.
13+
*
14+
* See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
15+
*/
16+
ssize_t uv__strscpy(char* d, const char* s, size_t n);
17+
18+
#endif /* UV_STRSCPY_H_ */

deps/uv/src/timer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int uv__next_timeout(const uv_loop_t* loop) {
152152
if (diff > INT_MAX)
153153
diff = INT_MAX;
154154

155-
return diff;
155+
return (int) diff;
156156
}
157157

158158

deps/uv/src/unix/aix.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,15 @@ void uv_loadavg(double avg[3]) {
358358

359359

360360
#ifdef HAVE_SYS_AHAFS_EVPRODS_H
361-
static char *uv__rawname(char *cp) {
362-
static char rawbuf[FILENAME_MAX+1];
363-
char *dp = rindex(cp, '/');
361+
static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) {
362+
char* dp;
364363

364+
dp = rindex(cp, '/');
365365
if (dp == 0)
366366
return 0;
367367

368-
*dp = 0;
369-
strcpy(rawbuf, cp);
370-
*dp = '/';
371-
strcat(rawbuf, "/r");
372-
strcat(rawbuf, dp+1);
373-
return rawbuf;
368+
snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1);
369+
return *dst;
374370
}
375371

376372

@@ -399,6 +395,7 @@ static int uv__path_is_a_directory(char* filename) {
399395
* Returns 0 if AHAFS is mounted, or an error code < 0 on failure
400396
*/
401397
static int uv__is_ahafs_mounted(void){
398+
char rawbuf[FILENAME_MAX+1];
402399
int rv, i = 2;
403400
struct vmount *p;
404401
int size_multiplier = 10;
@@ -432,7 +429,7 @@ static int uv__is_ahafs_mounted(void){
432429
obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */
433430
stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */
434431

435-
if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) {
432+
if (EQ(obj, dev) || EQ(uv__rawname(obj, &rawbuf), dev) || EQ(stub, dev)) {
436433
uv__free(p); /* Found a match */
437434
return 0;
438435
}
@@ -453,7 +450,8 @@ static int uv__makedir_p(const char *dir) {
453450
size_t len;
454451
int err;
455452

456-
snprintf(tmp, sizeof(tmp),"%s",dir);
453+
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
454+
uv__strscpy(tmp, dir, sizeof(tmp));
457455
len = strlen(tmp);
458456
if (tmp[len - 1] == '/')
459457
tmp[len - 1] = 0;
@@ -702,9 +700,9 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int
702700
else
703701
p++;
704702
}
705-
strncpy(fname, p, sizeof(fname) - 1);
706-
/* Just in case */
707-
fname[sizeof(fname) - 1] = '\0';
703+
704+
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
705+
uv__strscpy(fname, p, sizeof(fname));
708706

709707
handle->cb(handle, fname, events, 0);
710708
}
@@ -735,7 +733,8 @@ int uv_fs_event_start(uv_fs_event_t* handle,
735733
/* Figure out whether filename is absolute or not */
736734
if (filename[0] == '/') {
737735
/* We have absolute pathname */
738-
snprintf(absolute_path, sizeof(absolute_path), "%s", filename);
736+
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
737+
uv__strscpy(absolute_path, filename, sizeof(absolute_path));
739738
} else {
740739
/* We have a relative pathname, compose the absolute pathname */
741740
snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid());
@@ -986,7 +985,8 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
986985
return UV_ENOMEM;
987986
}
988987

989-
strcpy(cpu_id.name, FIRST_CPU);
988+
/* TODO(bnoordhuis) Check uv__strscpy() return value. */
989+
uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name));
990990
result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus);
991991
if (result == -1) {
992992
uv__free(ps_cpus);

deps/uv/src/unix/darwin-proctitle.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ void uv__set_process_title(const char* title) {
192192

193193
if (dynamic_pthread_setname_np != NULL) {
194194
char namebuf[64]; /* MAXTHREADNAMESIZE */
195-
strncpy(namebuf, title, sizeof(namebuf) - 1);
196-
namebuf[sizeof(namebuf) - 1] = '\0';
195+
uv__strscpy(namebuf, title, sizeof(namebuf));
197196
dynamic_pthread_setname_np(namebuf);
198197
}
199198
}

deps/uv/src/unix/fs.c

+31-11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
#if defined(__APPLE__)
6363
# include <copyfile.h>
64+
# include <sys/sysctl.h>
6465
#elif defined(__linux__) && !defined(FICLONE)
6566
# include <sys/ioctl.h>
6667
# define FICLONE _IOW(0x94, 9, int)
@@ -70,6 +71,10 @@
7071
# include <utime.h>
7172
#endif
7273

74+
#if defined(_AIX) && _XOPEN_SOURCE <= 600
75+
extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
76+
#endif
77+
7378
#define INIT(subtype) \
7479
do { \
7580
if (req == NULL) \
@@ -722,7 +727,7 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
722727
atr.att_atimechg = 1;
723728
atr.att_mtime = req->mtime;
724729
atr.att_atime = req->atime;
725-
return __lchattr(req->path, &atr, sizeof(atr));
730+
return __lchattr((char*) req->path, &atr, sizeof(atr));
726731
#else
727732
errno = ENOSYS;
728733
return -1;
@@ -793,26 +798,41 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
793798
static ssize_t uv__fs_copyfile(uv_fs_t* req) {
794799
#if defined(__APPLE__) && !TARGET_OS_IPHONE
795800
/* On macOS, use the native copyfile(3). */
801+
static int can_clone;
796802
copyfile_flags_t flags;
803+
char buf[64];
804+
size_t len;
805+
int major;
797806

798807
flags = COPYFILE_ALL;
799808

800809
if (req->flags & UV_FS_COPYFILE_EXCL)
801810
flags |= COPYFILE_EXCL;
802811

803-
#ifdef COPYFILE_CLONE
804-
if (req->flags & UV_FS_COPYFILE_FICLONE)
805-
flags |= COPYFILE_CLONE;
806-
#endif
807-
812+
/* Check OS version. Cloning is only supported on macOS >= 10.12. */
808813
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
809-
#ifdef COPYFILE_CLONE_FORCE
810-
flags |= COPYFILE_CLONE_FORCE;
811-
#else
812-
return UV_ENOSYS;
813-
#endif
814+
if (can_clone == 0) {
815+
len = sizeof(buf);
816+
if (sysctlbyname("kern.osrelease", buf, &len, NULL, 0))
817+
return UV__ERR(errno);
818+
819+
if (1 != sscanf(buf, "%d", &major))
820+
abort();
821+
822+
can_clone = -1 + 2 * (major >= 16); /* macOS >= 10.12 */
823+
}
824+
825+
if (can_clone < 0)
826+
return UV_ENOSYS;
814827
}
815828

829+
/* copyfile() simply ignores COPYFILE_CLONE if it's not supported. */
830+
if (req->flags & UV_FS_COPYFILE_FICLONE)
831+
flags |= 1 << 24; /* COPYFILE_CLONE */
832+
833+
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE)
834+
flags |= 1 << 25; /* COPYFILE_CLONE_FORCE */
835+
816836
return copyfile(req->path, req->new_path, NULL, flags);
817837
#else
818838
uv_fs_t fs_req;

0 commit comments

Comments
 (0)