Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/gen/t_nice.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/gen/t_nice.c (revision 313468) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/gen/t_nice.c (revision 313469) @@ -1,221 +1,216 @@ /* $NetBSD: t_nice.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __RCSID("$NetBSD: t_nice.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $"); #include #include #include #include #include #include #include #include static void *threadfunc(void *); static void * threadfunc(void *arg) { int pri, val; val = *(int *)arg; errno = 0; pri = getpriority(PRIO_PROCESS, 0); ATF_REQUIRE(errno == 0); if (pri != val) atf_tc_fail("nice(3) value was not propagated to threads"); return NULL; } ATF_TC(nice_err); ATF_TC_HEAD(nice_err, tc) { atf_tc_set_md_var(tc, "descr", "Test nice(3) for invalid parameters (PR lib/42587)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(nice_err, tc) { int i; -#ifdef __FreeBSD__ - atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged " - "users and sets errno == EPERM; see PR # 189821 for more details"); -#endif - /* * The call should fail with EPERM if the * supplied parameter is negative and the * caller does not have privileges. */ for (i = -20; i < 0; i++) { errno = 0; ATF_REQUIRE_ERRNO(EPERM, nice(i) == -1); } } ATF_TC(nice_priority); ATF_TC_HEAD(nice_priority, tc) { atf_tc_set_md_var(tc, "descr", "Test nice(3) vs. getpriority(2)"); } ATF_TC_BODY(nice_priority, tc) { #ifdef __FreeBSD__ int i, pri, pri2, nic; #else int i, pri, nic; #endif pid_t pid; int sta; for (i = 0; i <= 20; i++) { nic = nice(i); ATF_REQUIRE(nic != -1); errno = 0; pri = getpriority(PRIO_PROCESS, 0); ATF_REQUIRE(errno == 0); #ifdef __NetBSD__ if (nic != pri) atf_tc_fail("nice(3) and getpriority(2) conflict"); #endif /* * Also verify that the nice(3) values * are inherited by child processes. */ pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { errno = 0; #ifdef __FreeBSD__ pri = getpriority(PRIO_PROCESS, 0); #else pri2 = getpriority(PRIO_PROCESS, 0); #endif ATF_REQUIRE(errno == 0); #ifdef __FreeBSD__ if (pri != pri2) #else if (nic != pri) #endif _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("nice(3) value was not inherited"); } } ATF_TC(nice_root); ATF_TC_HEAD(nice_root, tc) { atf_tc_set_md_var(tc, "descr", "Test that nice(3) works"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(nice_root, tc) { int i; for (i = -20; i <= 20; i++) { ATF_REQUIRE(nice(i) != -1); } } ATF_TC(nice_thread); ATF_TC_HEAD(nice_thread, tc) { atf_tc_set_md_var(tc, "descr", "Test nice(3) with threads"); } ATF_TC_BODY(nice_thread, tc) { pthread_t tid[5]; #ifdef __FreeBSD__ int pri, rv, val; #else int rv, val; #endif size_t i; /* * Test that the scheduling priority is * propagated to all system scope threads. */ for (i = 0; i < __arraycount(tid); i++) { val = nice(i); ATF_REQUIRE(val != -1); #ifdef __FreeBSD__ pri = getpriority(PRIO_PROCESS, 0); rv = pthread_create(&tid[i], NULL, threadfunc, &pri); #else rv = pthread_create(&tid[i], NULL, threadfunc, &val); #endif ATF_REQUIRE(rv == 0); rv = pthread_join(tid[i], NULL); ATF_REQUIRE(rv == 0); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, nice_err); ATF_TP_ADD_TC(tp, nice_priority); ATF_TP_ADD_TC(tp, nice_root); ATF_TP_ADD_TC(tp, nice_thread); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/string/t_memmem.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/string/t_memmem.c (revision 313468) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/string/t_memmem.c (revision 313469) @@ -1,105 +1,105 @@ /* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Perry E. Metzger of Metzger, Dowdeswell & Co. LLC. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include char p0[] = ""; int lp0 = 0; char p1[] = "0123"; int lp1 = 4; char p2[] = "456"; int lp2 = 3; char p3[] = "789"; int lp3 = 3; char p4[] = "abc"; int lp4 = 3; char p5[] = "0"; int lp5 = 1; char p6[] = "9"; int lp6 = 1; char p7[] = "654"; int lp7 = 3; char b0[] = ""; int lb0 = 0; char b1[] = "0"; int lb1 = 1; char b2[] = "0123456789"; int lb2 = 10; #define expect(b) \ if (!(b)) { \ fprintf(stderr, "failed on line %d\n", __LINE__); \ atf_tc_fail("Check stderr for test id/line"); \ } ATF_TC(memmem_basic); ATF_TC_HEAD(memmem_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test memmem results"); } ATF_TC_BODY(memmem_basic, tc) { -#if defined(__darwin__) || defined(__FreeBSD__) +#if defined(__darwin__) expect(memmem(b2, lb2, p0, lp0) == NULL); expect(memmem(b0, lb0, p0, lp0) == NULL); #else expect(memmem(b2, lb2, p0, lp0) == b2); expect(memmem(b0, lb0, p0, lp0) == b0); #endif expect(memmem(b0, lb0, p1, lp1) == NULL); expect(memmem(b1, lb1, p1, lp1) == NULL); expect(memmem(b2, lb2, p1, lp1) == b2); expect(memmem(b2, lb2, p2, lp2) == (b2 + 4)); expect(memmem(b2, lb2, p3, lp3) == (b2 + 7)); expect(memmem(b2, lb2, p5, lp5) == b2); expect(memmem(b2, lb2, p6, lp6) == (b2 + 9)); expect(memmem(b2, lb2, p4, lp4) == NULL); expect(memmem(b2, lb2, p7, lp7) == NULL); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, memmem_basic); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/lib/libc/gen/nice.3 =================================================================== --- projects/stable-10-backport-test-changes/lib/libc/gen/nice.3 (revision 313468) +++ projects/stable-10-backport-test-changes/lib/libc/gen/nice.3 (revision 313469) @@ -1,69 +1,97 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)nice.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd February 28, 2015 .Dt NICE 3 .Os .Sh NAME .Nm nice .Nd set program scheduling priority .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn nice "int incr" .Sh DESCRIPTION .Bf -symbolic This interface is obsoleted by .Xr setpriority 2 . .Ef .Pp The .Fn nice -function obtains the scheduling priority of the process -from the system and sets it to the priority value specified in -.Fa incr . +function adds +.Fa incr +to the scheduling priority of the process. The priority is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. Only the super-user may lower priorities. .Pp Children inherit the priority of their parent processes via .Xr fork 2 . +.Sh RETURN VALUES +Upon successful completion, +.Fn nice +returns 0, and +.Va errno +is unchanged. +Otherwise, \-1 is returned, the process' nice value is not changed, and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn nice +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The +.Fa incr +argument is negative and the caller does not have appropriate privileges. +.El .Sh SEE ALSO .Xr nice 1 , .Xr fork 2 , .Xr setpriority 2 , .Xr renice 8 +.Sh STANDARDS +The +.Fn nice +function conforms to +.St -p1003.1-2008 +except for the return value. +This implementation returns 0 upon successful completion but +the standard requires returning the new nice value, +which could be \-1. .Sh HISTORY A .Fn nice syscall appeared in .At v6 . Index: projects/stable-10-backport-test-changes/lib/libc/gen/nice.c =================================================================== --- projects/stable-10-backport-test-changes/lib/libc/gen/nice.c (revision 313468) +++ projects/stable-10-backport-test-changes/lib/libc/gen/nice.c (revision 313469) @@ -1,56 +1,62 @@ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include /* * Backwards compatible nice. */ int -nice(incr) - int incr; +nice(int incr) { - int prio; + int saverrno, prio; + saverrno = errno; errno = 0; prio = getpriority(PRIO_PROCESS, 0); - if (prio == -1 && errno) + if (prio == -1 && errno != 0) return (-1); - return (setpriority(PRIO_PROCESS, 0, prio + incr)); + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { + if (errno == EACCES) + errno = EPERM; + return (-1); + } + errno = saverrno; + return (0); } Index: projects/stable-10-backport-test-changes/lib/libc/string/memmem.3 =================================================================== --- projects/stable-10-backport-test-changes/lib/libc/string/memmem.3 (revision 313468) +++ projects/stable-10-backport-test-changes/lib/libc/string/memmem.3 (revision 313469) @@ -1,86 +1,92 @@ .\" Copyright (c) 2005 Pascal Gloor .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote .\" products derived from this software without specific prior written .\" permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd August 24, 2005 +.Dd May 26, 2015 .Dt MEMMEM 3 .Os .Sh NAME .Nm memmem .Nd "locate a byte substring in a byte string" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In string.h .Ft "void *" .Fo memmem .Fa "const void *big" "size_t big_len" .Fa "const void *little" "size_t little_len" .Fc .Sh DESCRIPTION The .Fn memmem function locates the first occurrence of the byte string .Fa little in the byte string .Fa big . .Sh RETURN VALUES If -.Fa big_len -is smaller than -.Fa little_len , -if .Fa little_len -is 0, if -.Fa big_len -is 0 or if +is zero +.Fa big +is returned (that is, an empty little is deemed to match at the beginning of +big); +if .Fa little occurs nowhere in .Fa big , .Dv NULL is returned; otherwise a pointer to the first character of the first occurrence of .Fa little is returned. .Sh SEE ALSO .Xr memchr 3 , .Xr strchr 3 , .Xr strstr 3 .Sh CONFORMING TO .Fn memmem is a GNU extension. .Sh HISTORY The .Fn memmem function first appeared in .Fx 6.0 . .Sh AUTHORS .An Pascal Gloor Aq pascal.gloor@spale.com .Sh BUGS This function was broken in Linux libc up to and including version 5.0.9 and in GNU libc prior to version 2.1. +Prior to +.Fx 11.0 +.Nm +returned +.Dv NULL +when +.Fa little_len +equals 0. Index: projects/stable-10-backport-test-changes/lib/libc/string/memmem.c =================================================================== --- projects/stable-10-backport-test-changes/lib/libc/string/memmem.c (revision 313468) +++ projects/stable-10-backport-test-changes/lib/libc/string/memmem.c (revision 313469) @@ -1,65 +1,65 @@ /*- * Copyright (c) 2005 Pascal Gloor * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include /* * Find the first occurrence of the byte string s in byte string l. */ void * memmem(const void *l, size_t l_len, const void *s, size_t s_len) { register char *cur, *last; const char *cl = (const char *)l; const char *cs = (const char *)s; - /* we need something to compare */ - if (l_len == 0 || s_len == 0) - return NULL; + /* empty "s" matches the beginning of "l" */ + if (s_len == 0) + return (void *)cl; /* "s" must be smaller or equal to "l" */ if (l_len < s_len) return NULL; /* special case where s_len == 1 */ if (s_len == 1) return memchr(l, (int)*cs, l_len); /* the last position where its possible to find "s" in "l" */ last = (char *)cl + l_len - s_len; for (cur = (char *)cl; cur <= last; cur++) if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0) return cur; return NULL; } Index: projects/stable-10-backport-test-changes =================================================================== --- projects/stable-10-backport-test-changes (revision 313468) +++ projects/stable-10-backport-test-changes (revision 313469) Property changes on: projects/stable-10-backport-test-changes ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r279154,279397,283584