From 53a08c47dc008c1a26310a622e72b42d0f88f791 Mon Sep 17 00:00:00 2001 From: jilles Date: Fri, 15 Jan 2016 20:55:44 +0000 Subject: MFC r293783: futimens/utimensat: Use the new system calls. Update the __FreeBSD_version check in lib/libc/sys/futimens.c and lib/libc/sys/utimensat.c. Before this, fallback code using futimes/futimesat/lutimes was used except when running on a sufficiently recent 11-current kernel. Also, update the history section in the man page. --- lib/libc/sys/futimens.c | 5 ++++- lib/libc/sys/utimensat.2 | 4 ++-- lib/libc/sys/utimensat.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/futimens.c b/lib/libc/sys/futimens.c index 2014cc5..59fb37f 100644 --- a/lib/libc/sys/futimens.c +++ b/lib/libc/sys/futimens.c @@ -42,8 +42,11 @@ futimens(int fd, const struct timespec times[2]) { struct timeval now, tv[2], *tvp; struct stat sb; + int osreldate; - if (__getosreldate() >= 1100056) + osreldate = __getosreldate(); + if (osreldate >= 1100056 || + (osreldate >= 1002506 && osreldate < 1100000)) return (__sys_futimens(fd, times)); if (times == NULL || (times[0].tv_nsec == UTIME_NOW && diff --git a/lib/libc/sys/utimensat.2 b/lib/libc/sys/utimensat.2 index 0f397c6..57ad904 100644 --- a/lib/libc/sys/utimensat.2 +++ b/lib/libc/sys/utimensat.2 @@ -31,7 +31,7 @@ .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 23, 2015 +.Dd January 12, 2016 .Dt UTIMENSAT 2 .Os .Sh NAME @@ -289,4 +289,4 @@ The and .Fn utimensat system calls appeared in -.Fx 11.0 . +.Fx 10.3 . diff --git a/lib/libc/sys/utimensat.c b/lib/libc/sys/utimensat.c index 67d19cb..a1c3c21 100644 --- a/lib/libc/sys/utimensat.c +++ b/lib/libc/sys/utimensat.c @@ -42,8 +42,11 @@ utimensat(int fd, const char *path, const struct timespec times[2], int flag) { struct timeval now, tv[2], *tvp; struct stat sb; + int osreldate; - if (__getosreldate() >= 1100056) + osreldate = __getosreldate(); + if (osreldate >= 1100056 || + (osreldate >= 1002506 && osreldate < 1100000)) return (__sys_utimensat(fd, path, times, flag)); if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) { -- cgit v1.1 From bc1e3287c3f8c8833ec8e749018df75bd7cc31e1 Mon Sep 17 00:00:00 2001 From: tuexen Date: Sat, 16 Jan 2016 14:56:30 +0000 Subject: MFC r287619: Zero out a local variable also when PURIFY is not defined. This silence a warning brought up by valgrind whenever if_nametoindex is used. This was already discussed in PR 166483, but the code committed in r234329 guards the initilization with #ifdef PURIFY. Therefore, valgrind still complains. Since this code is not performance critical, always zero out the local variable to silence valgrind. --- lib/libc/net/if_nametoindex.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c index 8f04921..debf3fa 100644 --- a/lib/libc/net/if_nametoindex.c +++ b/lib/libc/net/if_nametoindex.c @@ -70,9 +70,7 @@ if_nametoindex(const char *ifname) s = _socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (s != -1) { -#ifdef PURIFY memset(&ifr, 0, sizeof(ifr)); -#endif strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) { _close(s); -- cgit v1.1 From 2e97bc7968d26612ada09a355c97b09c7c647a3f Mon Sep 17 00:00:00 2001 From: ngie Date: Mon, 18 Jan 2016 03:47:46 +0000 Subject: MFC r293704: Fix theoretical leak of netconfig(3) resources in svcunix_create(..) In the event that the getconfig(3) call in svcunix_create is partly successful, some of the netconfig(3) resources allocated might be leaked if the call returns NULL as endnetconfig(3) wasn't called explicitly in that case. Ensure that the resources are fully cleaned up by going to the `done` label, which will call endnetconfig(3) for us. Submitted by: Miles Ohlrich --- lib/libc/rpc/rpc_soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index 8d0f34e..ff7a289 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -525,7 +525,7 @@ svcunix_create(sock, sendsize, recvsize, path) break; } if (nconf == NULL) - return(xprt); + goto done; if ((sock = __rpc_nconf2fd(nconf)) < 0) goto done; -- cgit v1.1 From 6391e7176199f2b99c1f8d3e9d1a218b254a5fc6 Mon Sep 17 00:00:00 2001 From: ngie Date: Mon, 18 Jan 2016 03:49:57 +0000 Subject: MFC r293705: Similar to r293704, fix theoretical leak of netconfig(3) resources in __rpcbind_is_up(..) if getnetconfig(3) is partly successful in allocating resources, but not completely successful by moving the endnetconfig(3) call up before we return from the function if nconf == NULL. Submitted by: Miles Ohlrich --- lib/libc/rpc/rpcb_clnt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index 943d7c8..117ee0f 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -675,11 +675,11 @@ __rpcbind_is_up() strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) break; } + endnetconfig(localhandle); + if (nconf == NULL) return (FALSE); - endnetconfig(localhandle); - memset(&sun, 0, sizeof sun); sock = _socket(AF_LOCAL, SOCK_STREAM, 0); if (sock < 0) -- cgit v1.1 From 95e3008df9dacdefc14557f98920587b391f3b2b Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 19 Jan 2016 01:30:22 +0000 Subject: MFC r293715: Fix a mismerge from NetBSD in r162194 with `xdr_rpcb_entry_list_ptr(..)` This fixes the potential NULL pointer dereference properly, and also fixes memory leaks encountered in the process of iterating through `*rp`. Found by: Valgrind Submitted by: Miles Ohlrich --- lib/libc/rpc/rpcb_prot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c index f543aaf..92463c0 100644 --- a/lib/libc/rpc/rpcb_prot.c +++ b/lib/libc/rpc/rpcb_prot.c @@ -217,14 +217,14 @@ xdr_rpcb_entry_list_ptr(xdrs, rp) * the case of freeing we must remember the next object * before we free the current object ... */ - if (freeing) + if (freeing && *rp) next = (*rp)->rpcb_entry_next; if (! xdr_reference(xdrs, (caddr_t *)rp, (u_int)sizeof (rpcb_entry_list), (xdrproc_t)xdr_rpcb_entry)) { return (FALSE); } - if (freeing && *rp) { + if (freeing) { next_copy = next; rp = &next_copy; /* -- cgit v1.1 From 223081e0c89077309760cd2f5ce595677493432e Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 19 Jan 2016 23:18:49 +0000 Subject: Default __MAKE_SHELL to /bin/sh when generating aton_ether_subr.c via `gen_ether_subr`. __MAKE_SHELL is only defined when installworld is run on stable/10, which breaks workflows dealing with source trees mounted with noexec [*] This is a direct commit to stable/10 Reported by: Mark Martinec Sponsored by: EMC / Isilon Storage Division --- lib/libc/tests/net/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile index a88f44f..fb76f26 100644 --- a/lib/libc/tests/net/Makefile +++ b/lib/libc/tests/net/Makefile @@ -28,6 +28,8 @@ PROGS+= h_dns_server DPADD.h_nsd_recurse+= ${LIBPTHREAD} LDADD.h_nsd_recurse+= -lpthread +__MAKE_SHELL?= /bin/sh + CLEANFILES+= aton_ether_subr.c aton_ether_subr.c: gen_ether_subr ${.CURDIR:H:H:H:H}/sys/net/if_ethersubr.c ${__MAKE_SHELL} ${.ALLSRC} ${.TARGET} -- cgit v1.1 From e2eb05d1c781889c336a2514b104717f58ceddca Mon Sep 17 00:00:00 2001 From: brooks Date: Wed, 20 Jan 2016 19:08:49 +0000 Subject: MFC r293855: Avoid reading pass the end of the source buffer when it is not NUL terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206177 Submitted by: Alexander Cherepanov --- lib/libc/string/wcsncat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/string/wcsncat.c b/lib/libc/string/wcsncat.c index 44f1ff9..5a24347 100644 --- a/lib/libc/string/wcsncat.c +++ b/lib/libc/string/wcsncat.c @@ -48,7 +48,7 @@ wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n) p++; q = p; r = s2; - while (*r && n) { + while (n && *r) { *q++ = *r++; n--; } -- cgit v1.1 From 6ef41be39c6d896d6c5919661540ce76614b6e9e Mon Sep 17 00:00:00 2001 From: brooks Date: Wed, 20 Jan 2016 19:26:04 +0000 Subject: MFC r293856: Avoid reading pass the end of the source buffer when it is not NUL terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206178 Submitted by: Alexander Cherepanov --- lib/libc/string/wcslcat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/string/wcslcat.c b/lib/libc/string/wcslcat.c index f5f1e1e..2df9477 100644 --- a/lib/libc/string/wcslcat.c +++ b/lib/libc/string/wcslcat.c @@ -54,7 +54,7 @@ wcslcat(wchar_t *dst, const wchar_t *src, size_t siz) size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ - while (*d != '\0' && n-- != 0) + while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; -- cgit v1.1 From c749c94c2ec83d82c428b921de4efe12f1a02b49 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 21 Jan 2016 21:16:57 +0000 Subject: MFC r294234: utimensat(2): Correct description of [EINVAL] error. --- lib/libc/sys/utimensat.2 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/utimensat.2 b/lib/libc/sys/utimensat.2 index 57ad904..a714b34 100644 --- a/lib/libc/sys/utimensat.2 +++ b/lib/libc/sys/utimensat.2 @@ -31,7 +31,7 @@ .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 12, 2016 +.Dd January 17, 2016 .Dt UTIMENSAT 2 .Os .Sh NAME @@ -183,10 +183,13 @@ argument points outside the process's allocated address space. .It Bq Er EINVAL The -.Va tv_usec +.Va tv_nsec component of at least one of the values specified by the .Fa times -argument has a value less than 0 or greater than 999999. +argument has a value less than 0 or greater than 999999999 and is not equal to +.Dv UTIME_NOW +or +.Dv UTIME_OMIT . .It Bq Er EIO An I/O error occurred while reading or writing the affected inode. .It Bq Er EPERM -- cgit v1.1