Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
OSX: Add missing reallocarray and strchrnul
Vsevolod Stakhov committed 6 years ago
commit ec218b1c934afc9a53c48b1bc9db05e796604bde
parent 5475003
2 files changed +10 -2
modified auto.def
@@ -148,7 +148,7 @@ cc-check-includes stdint.h inttypes.h
cc-check-functions arc4random arc4random_stir basename_r chflagsat \
	closefrom dirfd eaccess fopencookie fstatfs funopen strnstr \
	strtofflags strtonum sysconf utimensat __res_setservers unlinkat \
-
	faccessat fstatat openat readlinkat fflagstostr
+
	faccessat fstatat openat readlinkat fflagstostr reallocarray strchrnul

cc-with { -includes { libutil.h }} {
	if {[cc-check-decls humanize_number]} {
modified external/libfetch/common.c
@@ -272,7 +272,11 @@ fetch_resolve(const char *addr, int port, int af)
		he = sep++;
	} else {
		hb = addr;
-
		sep = strchrnul(hb, ':');
+
#if HAVE_STRCHRNUL
+
    sep = strchrnul(hb, ':');
+
#else
+
    do{ sep++; }while( *sep && *sep != ':' );
+
#endif
		he = sep;
	}

@@ -1443,7 +1447,11 @@ fetch_add_entry(struct url_ent **p, int *size, int *len,
	}

	if (*len >= *size - 1) {
+
#if !HAVE_REALLOCARRAY
+
		tmp = realloc(*p, (*size * 2 + 1) * sizeof(**p));
+
#else
		tmp = reallocarray(*p, *size * 2 + 1, sizeof(**p));
+
#endif
		if (tmp == NULL) {
			errno = ENOMEM;
			fetch_syserr();