From owner-freebsd-standards@FreeBSD.ORG Mon Mar 30 11:07:01 2009 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EC451065673 for ; Mon, 30 Mar 2009 11:07:01 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 4A3938FC35 for ; Mon, 30 Mar 2009 11:07:01 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n2UB7187054919 for ; Mon, 30 Mar 2009 11:07:01 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n2UB70Hg054915 for freebsd-standards@FreeBSD.org; Mon, 30 Mar 2009 11:07:00 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 30 Mar 2009 11:07:00 GMT Message-Id: <200903301107.n2UB70Hg054915@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-standards@FreeBSD.org X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2009 11:07:02 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o stand/130067 standards Wrong numeric limits in system headers? o stand/129554 standards lp(1) [patch] Implement -m and -t options o stand/129524 standards FreeBSD 7.0 isnt detecting my hardrives with raid5 o stand/128546 standards ls -p does not follow symlinks o bin/125855 standards sh(1) allows for multiline, non-escaped control struct o stand/124860 standards flockfile(3) doesn't work when the memory has been exh o stand/123688 standards POSIX standard changes in unistd.h and grp.h o stand/121921 standards [patch] Add leap second support to at(1), atrun(8) o stand/121568 standards [patch] ln(1): wrong "ln -s" behaviour o stand/120947 standards xsm ignores system.xsm and .xsmstartup o stand/119804 standards [locale] [patch] Invalid (long)date format in pl_PL.IS o stand/116826 standards [patch] sh support for POSIX character classes o stand/116477 standards rm(1): rm behaves unexpectedly when using -r and relat o bin/116413 standards incorrect getconf(1) handling of unsigned constants gi o stand/116081 standards make does not work with the directive sinclude p stand/107561 standards [libc] [patch] [request] Missing SUS function tcgetsid o stand/104743 standards [headers] [patch] Wrong values for _POSIX_ minimal lim o stand/100017 standards [Patch] Add fuser(1) functionality to fstat(1) o stand/96236 standards [patch] [posix] sed(1) incorrectly describes a functio o stand/96016 standards [headers] clock_getres et al should be in o stand/94729 standards [libc] fcntl() throws undocumented ENOTTY o kern/93705 standards [headers] [patch] ENODATA and EGREGIOUS (for glibc com o stand/92362 standards [headers] [patch] Missing SIGPOLL in kernel headers a stand/86484 standards [patch] mkfifo(1) uses wrong permissions o stand/83845 standards [libm] [patch] add log2() and log2f() support for libm o stand/82654 standards C99 long double math functions are missing o stand/81287 standards [patch] fingerd(8) might send a line not ending in CRL a stand/80293 standards sysconf() does not support well-defined unistd values o stand/79056 standards [feature request] [atch] regex(3) regression tests o stand/70813 standards [patch] ls(1) not Posix compliant o stand/66357 standards make POSIX conformance problem ('sh -e' & '+' command- s kern/64875 standards [libc] [patch] [request] add a system call: fdatasync( s stand/62858 standards malloc(0) not C99 compliant o stand/56476 standards cd9660 unicode support simple hack p stand/55112 standards glob.h, glob_t's gl_pathc should be "size_t", not "int o stand/54839 standards [pcvt] pcvt deficits o stand/54833 standards [pcvt] more pcvt deficits o stand/54410 standards one-true-awk not POSIX compliant (no extended REs) o stand/46119 standards Priority problems for SCHED_OTHER using pthreads o stand/44425 standards getcwd() succeeds even if current dir has perm 000. p stand/41576 standards POSIX compliance of ln(1) o stand/39256 standards snprintf/vsnprintf aren't POSIX-conformant for strings s stand/36076 standards Implementation of POSIX fuser command o kern/27835 standards [libc] execve() doesn't conform to execve(2) spec in s a docs/26003 standards getgroups(2) lists NGROUPS_MAX but not syslimits.h o stand/25777 standards [kernel] [patch] atime not updated on exec o bin/25542 standards sh(1) null char in quoted string s stand/24590 standards timezone function not compatible witn Single Unix Spec o bin/24390 standards ln(1) Replacing old dir-symlinks when using /bin/ln o stand/21519 standards sys/dir.h should be deprecated some more s bin/14925 standards getsubopt isn't poisonous enough 51 problems total. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 3 12:50:02 2009 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56E36106566B for ; Fri, 3 Apr 2009 12:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2DEBA8FC26 for ; Fri, 3 Apr 2009 12:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n33Co2hc046010 for ; Fri, 3 Apr 2009 12:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n33Co2O4046009; Fri, 3 Apr 2009 12:50:02 GMT (envelope-from gnats) Resent-Date: Fri, 3 Apr 2009 12:50:02 GMT Resent-Message-Id: <200904031250.n33Co2O4046009@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tijl Coosemans Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 049FB106568C for ; Fri, 3 Apr 2009 12:47:12 +0000 (UTC) (envelope-from tijl@kalimero.kotnet.org) Received: from mailrelay004.isp.belgacom.be (mailrelay004.isp.belgacom.be [195.238.6.170]) by mx1.freebsd.org (Postfix) with ESMTP id 94F0F8FC1C for ; Fri, 3 Apr 2009 12:47:11 +0000 (UTC) (envelope-from tijl@kalimero.kotnet.org) Received: from 107.213-244-81.adsl-dyn.isp.belgacom.be (HELO kalimero.kotnet.org) ([81.244.213.107]) by relay.skynet.be with ESMTP; 03 Apr 2009 14:47:09 +0200 Received: from kalimero.kotnet.org (kalimero.kotnet.org [127.0.0.1]) by kalimero.kotnet.org (8.14.3/8.14.3) with ESMTP id n33Cl4MC006872 for ; Fri, 3 Apr 2009 14:47:04 +0200 (CEST) (envelope-from tijl@kalimero.kotnet.org) Received: (from tijl@localhost) by kalimero.kotnet.org (8.14.3/8.14.3/Submit) id n33Cl4Dn006871; Fri, 3 Apr 2009 14:47:04 +0200 (CEST) (envelope-from tijl) Message-Id: <200904031247.n33Cl4Dn006871@kalimero.kotnet.org> Date: Fri, 3 Apr 2009 14:47:04 +0200 (CEST) From: Tijl Coosemans To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: standards/133339: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT, ... X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tijl Coosemans List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2009 12:50:02 -0000 >Number: 133339 >Category: standards >Synopsis: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT,... >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Apr 03 12:50:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Tijl Coosemans >Release: FreeBSD 7.1-STABLE i386 >Organization: >Environment: FreeBSD 7.1-STABLE #4: Tue Mar 10 16:04:51 CET 2009 >Description: The dlfunc(3) function doesn't respect special handles like NULL, RTLD_SELF, RTLD_NEXT as explained in the manpage. In those cases dlsym(3) determines the list of objects to search through by looking at the return address on the stack to figure out which object the call originated from. Because dlfunc has been implemented in libc as a simple wrapper around dlsym, the return address on the stack points to libc and not the object the call originated from like the main program or another library. >How-To-Repeat: I've attached a small test program that should print the same address twice, but it currently prints NULL in the dlfunc case. >Fix: I'm guessing dlfunc has to be moved to rtld (strong alias to dlsym perhaps) and the current implementation in libc replaced with a dummy implementation like the other dl* functions in lib/libc/gen/dlfcn.c. --- test.c begins here --- #include #include int main( void ) { void *addr; addr = dlsym( RTLD_NEXT, "getpid" ); printf( "%p\n", addr ); /* this works */ addr = dlfunc( RTLD_NEXT, "getpid" ); printf( "%p\n", addr ); /* this prints NULL */ return( 0 ); } --- test.c ends here --- >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Fri Apr 3 19:32:51 2009 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB6381065673; Fri, 3 Apr 2009 19:32:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 9F85C8FC2E; Fri, 3 Apr 2009 19:32:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from freefall.freebsd.org (kib@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n33JWpMF098268; Fri, 3 Apr 2009 19:32:51 GMT (envelope-from kib@freefall.freebsd.org) Received: (from kib@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n33JWpF8098264; Fri, 3 Apr 2009 19:32:51 GMT (envelope-from kib) Date: Fri, 3 Apr 2009 19:32:51 GMT Message-Id: <200904031932.n33JWpF8098264@freefall.freebsd.org> To: tijl@ulyssis.org, kib@FreeBSD.org, freebsd-standards@FreeBSD.org, kib@FreeBSD.org From: kib@FreeBSD.org Cc: Subject: Re: standards/133339: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT, ... X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2009 19:32:52 -0000 Synopsis: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT,... State-Changed-From-To: open->patched State-Changed-By: kib State-Changed-When: Fri Apr 3 19:32:02 UTC 2009 State-Changed-Why: I committed the fix to HEAD. Responsible-Changed-From-To: freebsd-standards->kib Responsible-Changed-By: kib Responsible-Changed-When: Fri Apr 3 19:32:02 UTC 2009 Responsible-Changed-Why: Take. http://www.freebsd.org/cgi/query-pr.cgi?pr=133339 From owner-freebsd-standards@FreeBSD.ORG Sat Apr 4 11:06:50 2009 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C1FC106564A; Sat, 4 Apr 2009 11:06:50 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx0.stack.nl (mj0.stack.nl [IPv6:2001:610:1108:5010::187]) by mx1.freebsd.org (Postfix) with ESMTP id EAA488FC1C; Sat, 4 Apr 2009 11:06:49 +0000 (UTC) (envelope-from jilles@stack.nl) Received: by mx0.stack.nl (Postfix, from userid 65534) id 1AE192B34FE; Sat, 4 Apr 2009 13:06:49 +0200 (CEST) X-Spam-DCC: : X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on toad.stack.nl X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,FAKE_REPLY_C, J_CHICKENPOX_13,NO_RELAYS autolearn=no version=3.2.5 X-Spam-Relay-Country: Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx0.stack.nl (Postfix) with ESMTP id A55252B34CD; Sat, 4 Apr 2009 13:06:46 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 08E1A228A2; Sat, 4 Apr 2009 13:06:34 +0200 (CEST) Date: Sat, 4 Apr 2009 13:06:33 +0200 From: Jilles Tjoelker To: bug-followup@FreeBSD.org, vsevolod@highsecure.ru, freebsd-standards@freebsd.org, stefanf@freebsd.org Message-ID: <20090404110633.GA25666@stack.nl> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline X-Operating-System: FreeBSD 7.1-PRERELEASE i386 User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Subject: Re: standards/79067: /bin/sh should be more intelligent about IFS X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 11:06:50 -0000 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A patch similar to the 'read' part of this one was committed to -CURRENT. The other part of the patch in the PR is a bit different from NetBSD, and is wrong: it drops a final empty argument in "$@". For example, set -- a ''; set -- "$@"; echo $# should give 2, but gives 1. So I put in the NetBSD code, which does not have this issue (sh-ifs-expand-netbsd.patch). Additionally, it cleans up the code a bit. However, the NetBSD code has a related issue: it drops a final empty argument in "$@"$s where $s contains one or more characters of IFS whitespace. For example, s=' '; set -- a ''; set -- "$@"; echo $# should give 2, but gives 1. A fix for this is in sh-ifs-expand.patch. With the read change and both patches, the tests from http://www.research.att.com/~gsf/public/ifs.sh all pass. Some more tests with "$@" and IFS are in moreifs.sh. -- Jilles Tjoelker --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sh-ifs-expand-netbsd.patch" --- src/bin/sh/expand.c.orig 2008-09-04 19:34:53.000000000 +0200 +++ src/bin/sh/expand.c 2009-04-04 01:32:07.000000000 +0200 @@ -82,7 +82,7 @@ struct ifsregion *next; /* next region in list */ int begoff; /* offset of start of region */ int endoff; /* offset of end of region */ - int nulonly; /* search for nul bytes only */ + int inquotes; /* search for nul bytes only */ }; @@ -936,13 +936,19 @@ */ STATIC void -recordregion(int start, int end, int nulonly) +recordregion(int start, int end, int inquotes) { struct ifsregion *ifsp; if (ifslastp == NULL) { ifsp = &ifsfirst; } else { + if (ifslastp->endoff == start + && ifslastp->inquotes == inquotes) { + /* extend previous area */ + ifslastp->endoff = end; + return; + } ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion)); ifslastp->next = ifsp; } @@ -950,7 +956,7 @@ ifslastp->next = NULL; ifslastp->begoff = start; ifslastp->endoff = end; - ifslastp->nulonly = nulonly; + ifslastp->inquotes = inquotes; } @@ -969,75 +975,88 @@ char *p; char *q; char *ifs; - int ifsspc; - int nulonly; - + const char *ifsspc; + int had_param_ch = 0; start = string; - ifsspc = 0; - nulonly = 0; - if (ifslastp != NULL) { - ifsp = &ifsfirst; - do { - p = string + ifsp->begoff; - nulonly = ifsp->nulonly; - ifs = nulonly ? nullstr : - ( ifsset() ? ifsval() : " \t\n" ); - ifsspc = 0; - while (p < string + ifsp->endoff) { - q = p; - if (*p == CTLESC) + + if (ifslastp == NULL) { + /* Return entire argument, IFS doesn't apply to any of it */ + sp = (struct strlist *)stalloc(sizeof *sp); + sp->text = start; + *arglist->lastp = sp; + arglist->lastp = &sp->next; + return; + } + + ifs = ifsset() ? ifsval() : " \t\n"; + + for (ifsp = &ifsfirst; ifsp != NULL; ifsp = ifsp->next) { + p = string + ifsp->begoff; + while (p < string + ifsp->endoff) { + had_param_ch = 1; + q = p; + if (*p == CTLESC) + p++; + if (ifsp->inquotes) { + /* Only NULs (should be from "$@") end args */ + if (*p != 0) { p++; - if (strchr(ifs, *p)) { - if (!nulonly) - ifsspc = (strchr(" \t\n", *p) != NULL); - /* Ignore IFS whitespace at start */ - if (q == start && ifsspc) { - p++; - start = p; - continue; - } - *q = '\0'; - sp = (struct strlist *)stalloc(sizeof *sp); - sp->text = start; - *arglist->lastp = sp; - arglist->lastp = &sp->next; + continue; + } + ifsspc = NULL; + } else { + if (!strchr(ifs, *p)) { p++; - if (!nulonly) { - for (;;) { - if (p >= string + ifsp->endoff) { - break; - } - q = p; - if (*p == CTLESC) - p++; - if (strchr(ifs, *p) == NULL ) { - p = q; - break; - } else if (strchr(" \t\n",*p) == NULL) { - if (ifsspc) { - p++; - ifsspc = 0; - } else { - p = q; - break; - } - } else - p++; - } - } - start = p; - } else + continue; + } + had_param_ch = 0; + ifsspc = strchr(" \t\n", *p); + + /* Ignore IFS whitespace at start */ + if (q == start && ifsspc != NULL) { p++; + start = p; + continue; + } } - } while ((ifsp = ifsp->next) != NULL); - if (*start || (!ifsspc && start > string)) { + + /* Save this argument... */ + *q = '\0'; sp = (struct strlist *)stalloc(sizeof *sp); sp->text = start; *arglist->lastp = sp; arglist->lastp = &sp->next; + p++; + + if (ifsspc != NULL) { + /* Ignore further trailing IFS whitespace */ + for (; p < string + ifsp->endoff; p++) { + q = p; + if (*p == CTLESC) + p++; + if (strchr(ifs, *p) == NULL) { + p = q; + break; + } + if (strchr(" \t\n", *p) == NULL) { + p++; + break; + } + } + } + start = p; } - } else { + } + + /* + * Save anything left as an argument. + * Traditionally we have treated 'IFS=':'; set -- x$IFS' as + * generating 2 arguments, the second of which is empty. + * Some recent clarification of the Posix spec say that it + * should only generate one.... + */ + if (had_param_ch || *start != 0) { sp = (struct strlist *)stalloc(sizeof *sp); sp->text = start; *arglist->lastp = sp; --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sh-ifs-expand.patch" --- src/bin/sh/expand.c.netbsd 2009-04-04 01:32:07.000000000 +0200 +++ src/bin/sh/expand.c 2009-04-04 02:01:54.000000000 +0200 @@ -994,12 +994,12 @@ for (ifsp = &ifsfirst; ifsp != NULL; ifsp = ifsp->next) { p = string + ifsp->begoff; while (p < string + ifsp->endoff) { - had_param_ch = 1; q = p; if (*p == CTLESC) p++; if (ifsp->inquotes) { /* Only NULs (should be from "$@") end args */ + had_param_ch = 1; if (*p != 0) { p++; continue; @@ -1007,10 +1007,10 @@ ifsspc = NULL; } else { if (!strchr(ifs, *p)) { + had_param_ch = 1; p++; continue; } - had_param_ch = 0; ifsspc = strchr(" \t\n", *p); /* Ignore IFS whitespace at start */ @@ -1019,6 +1019,7 @@ start = p; continue; } + had_param_ch = 0; } /* Save this argument... */ --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="moreifs.sh" #!/bin/sh # Copyright (c) 2009 Jilles Tjoelker # 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. # # 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. # c=: e= s=' ' failures='' ok='' check_result() { if [ "x$2" = "x$3" ]; then ok=x$ok else failures=x$failures echo "For $1, expected $3 actual $2" fi } IFS=' ' set -- a '' set -- "$@" check_result 'set -- "$@"' "($#)($1)($2)" "(2)(a)()" set -- a '' set -- "$@"$e check_result 'set -- "$@"$e' "($#)($1)($2)" "(2)(a)()" set -- a '' set -- "$@"$s check_result 'set -- "$@"$s' "($#)($1)($2)" "(2)(a)()" IFS="$c" set -- a '' set -- "$@"$c check_result 'set -- "$@"$c' "($#)($1)($2)" "(2)(a)()" test "x$failures" = x --3V7upXqbjpZ4EhLz-- From owner-freebsd-standards@FreeBSD.ORG Sat Apr 4 12:50:04 2009 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D73C1065670 for ; Sat, 4 Apr 2009 12:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8CA7F8FC0A for ; Sat, 4 Apr 2009 12:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n34Co4L7028407 for ; Sat, 4 Apr 2009 12:50:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n34Co4Ej028406; Sat, 4 Apr 2009 12:50:04 GMT (envelope-from gnats) Date: Sat, 4 Apr 2009 12:50:04 GMT Message-Id: <200904041250.n34Co4Ej028406@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: bin/25542: sh(1) null char in quoted string X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 12:50:04 -0000 The following reply was made to PR bin/25542; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/25542: sh(1) null char in quoted string Date: Sat, 4 Apr 2009 14:41:43 +0200 Considering that fixing this would be a lot of work and cannot be done completely (for example, argument strings and environment variables cannot contain '\0'), I think it is best to close this. sh(1) is meant to process text, not binary data. Trying to process binary data may or will also cause problems if the locale character set is set to UTF-8. As a clarification, this PR is about '\0' bytes in shell scripts, not about making the echo builtin produce '\0' characters. The latter feature works fine and is good. -- Jilles Tjoelker From owner-freebsd-standards@FreeBSD.ORG Sat Apr 4 14:00:03 2009 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B4C31065672 for ; Sat, 4 Apr 2009 14:00:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 74EE38FC0C for ; Sat, 4 Apr 2009 14:00:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n34E03gS021833 for ; Sat, 4 Apr 2009 14:00:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n34E03S3021832; Sat, 4 Apr 2009 14:00:03 GMT (envelope-from gnats) Resent-Date: Sat, 4 Apr 2009 14:00:03 GMT Resent-Message-Id: <200904041400.n34E03S3021832@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jilles Tjoelker Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3AE3C106566B for ; Sat, 4 Apr 2009 13:50:46 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (unknown [IPv6:2001:610:1108:5000::149]) by mx1.freebsd.org (Postfix) with ESMTP id DDB7C8FC18 for ; Sat, 4 Apr 2009 13:50:45 +0000 (UTC) (envelope-from jilles@stack.nl) Received: by mx1.stack.nl (Postfix, from userid 65534) id 3F5673F7BA; Sat, 4 Apr 2009 15:50:45 +0200 (CEST) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id D906A3F5E6 for ; Sat, 4 Apr 2009 15:50:35 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 3C6E5228A2; Sat, 4 Apr 2009 15:50:23 +0200 (CEST) Message-Id: <20090404135023.3C6E5228A2@snail.stack.nl> Date: Sat, 4 Apr 2009 15:50:23 +0200 (CEST) From: Jilles Tjoelker To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: standards/133369: test(1) with 3 or 4 arguments X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 14:00:04 -0000 >Number: 133369 >Category: standards >Synopsis: test(1) with 3 or 4 arguments >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 04 14:00:03 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Jilles Tjoelker >Release: FreeBSD 7.2-PRERELEASE i386 >Organization: MCGV Stack >Environment: >Description: test(1) does not follow the rules in POSIX exactly if there are 3 or 4 arguments, different from what the man page says. In particular, different from what POSIX prescribes, test "$a" = "$b" does not work properly for all values of $a and $b. /bin/test and the test builtin in /bin/sh use the same code. >How-To-Repeat: An example, more tests are included in the patch. Input: /bin/test \( = \); echo $? Expected result: 1 Actual result: 0 According to POSIX, the rule about the second argument being a binary operator has priority above the rule about the first argument being '(' and the third argument being ')'. >Fix: Apply this patch. It includes additional test cases in TEST.sh. --- test-posixfixes.patch begins here --- --- src/bin/test/test.c.orig 2005-01-10 09:39:26.000000000 +0100 +++ src/bin/test/test.c 2009-04-02 02:28:28.000000000 +0200 @@ -163,6 +163,7 @@ struct t_op const *t_wp_op; int nargc; char **t_wp; +int parenlevel; static int aexpr(enum token); static int binop(void); @@ -171,7 +172,9 @@ static int getn(const char *); static intmax_t getq(const char *); static int intcmp(const char *, const char *); -static int isoperand(void); +static int isunopoperand(void); +static int islparenoperand(void); +static int isrparenoperand(void); static int newerf(const char *, const char *); static int nexpr(enum token); static int oexpr(enum token); @@ -205,7 +208,14 @@ #endif nargc = argc; t_wp = &argv[1]; - res = !oexpr(t_lex(*t_wp)); + parenlevel = 0; + if (nargc == 4 && strcmp(*t_wp, "!") == 0) { + /* Things like ! "" -o x do not fit in the normal grammar. */ + --nargc; + ++t_wp; + res = oexpr(t_lex(*t_wp)); + } else + res = !oexpr(t_lex(*t_wp)); if (--nargc > 0) syntax(*t_wp, "unexpected operator"); @@ -268,12 +278,16 @@ if (n == EOI) return 0; /* missing expression */ if (n == LPAREN) { + parenlevel++; if ((nn = t_lex(nargc > 0 ? (--nargc, *++t_wp) : NULL)) == - RPAREN) + RPAREN) { + parenlevel--; return 0; /* missing expression */ + } res = oexpr(nn); if (t_lex(nargc > 0 ? (--nargc, *++t_wp) : NULL) != RPAREN) syntax(NULL, "closing paren expected"); + parenlevel--; return res; } if (t_wp_op && t_wp_op->op_type == UNOP) { @@ -410,8 +424,10 @@ } while (op->op_text) { if (strcmp(s, op->op_text) == 0) { - if ((op->op_type == UNOP && isoperand()) || - (op->op_num == LPAREN && nargc == 1)) + if (((op->op_type == UNOP || op->op_type == BUNOP) + && isunopoperand()) || + (op->op_num == LPAREN && islparenoperand()) || + (op->op_num == RPAREN && isrparenoperand())) break; t_wp_op = op; return op->op_num; @@ -423,7 +439,7 @@ } static int -isoperand(void) +isunopoperand(void) { struct t_op const *op = ops; char *s; @@ -431,19 +447,53 @@ if (nargc == 1) return 1; - if (nargc == 2) - return 0; s = *(t_wp + 1); + if (nargc == 2) + return parenlevel == 1 && strcmp(s, ")") == 0; t = *(t_wp + 2); while (op->op_text) { if (strcmp(s, op->op_text) == 0) return op->op_type == BINOP && - (t[0] != ')' || t[1] != '\0'); + (parenlevel == 0 || t[0] != ')' || t[1] != '\0'); + op++; + } + return 0; +} + +static int +islparenoperand(void) +{ + struct t_op const *op = ops; + char *s; + + if (nargc == 1) + return 1; + s = *(t_wp + 1); + if (nargc == 2) + return parenlevel == 1 && strcmp(s, ")") == 0; + if (nargc != 3) + return 0; + while (op->op_text) { + if (strcmp(s, op->op_text) == 0) + return op->op_type == BINOP; op++; } return 0; } +static int +isrparenoperand(void) +{ + char *s; + + if (nargc == 1) + return 0; + s = *(t_wp + 1); + if (nargc == 2) + return parenlevel == 1 && strcmp(s, ")") == 0; + return 0; +} + /* atoi with error detection */ static int getn(const char *s) --- src/bin/test/TEST.sh.orig 2005-01-10 09:39:26.000000000 +0100 +++ src/bin/test/TEST.sh 2009-04-03 22:53:28.000000000 +0200 @@ -133,5 +133,35 @@ t 1 '""' t 0 '! ""' +t 0 '!' +t 0 '\(' +t 0 '\)' + +t 1 '\( = \)' +t 0 '\( != \)' +t 0 '\( ! \)' +t 0 '\( \( \)' +t 0 '\( \) \)' +t 0 '! = !' +t 1 '! != !' +t 1 '-n = \)' +t 0 '! != \)' +t 1 '! = a' +t 0 '! != -n' +t 0 '! -c /etc/passwd' + +t 0 '! \( = \)' +t 1 '! \( != \)' +t 1 '! = = =' +t 0 '! = = \)' +t 0 '! "" -o ""' +t 1 '! "x" -o ""' +t 1 '! "" -o "x"' +t 1 '! "x" -o "x"' +t 0 '\( -f /etc/passwd \)' +t 1 '\( ! = \)' +t 0 '\( ! "" \)' +t 1 '\( ! -e \)' + echo "" echo "Syntax errors: $ERROR Failed: $FAILED" --- test-posixfixes.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Sat Apr 4 14:56:45 2009 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34206106566B; Sat, 4 Apr 2009 14:56:45 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (unknown [IPv6:2001:610:1108:5000::149]) by mx1.freebsd.org (Postfix) with ESMTP id E8C4E8FC0A; Sat, 4 Apr 2009 14:56:44 +0000 (UTC) (envelope-from jilles@stack.nl) Received: by mx1.stack.nl (Postfix, from userid 65534) id 432513FB8F; Sat, 4 Apr 2009 16:56:44 +0200 (CEST) X-Spam-DCC: : X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on meestal-mk5.stack.nl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,FAKE_REPLY_C, NO_RELAYS autolearn=no version=3.2.3 X-Spam-Relay-Country: Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 791EF3FB8D; Sat, 4 Apr 2009 16:56:42 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id C9678228A2; Sat, 4 Apr 2009 16:56:29 +0200 (CEST) Date: Sat, 4 Apr 2009 16:56:29 +0200 From: Jilles Tjoelker To: bug-followup@FreeBSD.org, twschulz@trolltech.com, freebsd-standards@freebsd.org Message-ID: <20090404145629.GA31339@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Subject: Re: bin/108118: [libc] files should not cache their EOF status X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 14:56:45 -0000 The way I read POSIX, FreeBSD's current behaviour seems correct. Calling fread(3) is equivalent to calling fgetc(3) an appropriate number of times, and fgetc(3) shall fail if the end-of-file indicator is set for the stream, even if data is available on the underlying file. Apparently, POSIX aligns with the C standard here; System V tradition is not to check the end-of-file indicator here. Both src/lib/libc/stdio/refill.c (__srefill()) and Solaris fgetc(3) manpage agree about this. -- Jilles Tjoelker From owner-freebsd-standards@FreeBSD.ORG Sat Apr 4 19:26:20 2009 Return-Path: Delivered-To: standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66B371065679; Sat, 4 Apr 2009 19:26:20 +0000 (UTC) (envelope-from stefan@fafoe.narf.at) Received: from viefep19-int.chello.at (viefep19-int.chello.at [62.179.121.39]) by mx1.freebsd.org (Postfix) with ESMTP id 738298FC13; Sat, 4 Apr 2009 19:26:18 +0000 (UTC) (envelope-from stefan@fafoe.narf.at) Received: from edge05.upc.biz ([192.168.13.212]) by viefep16-int.chello.at (InterMail vM.7.09.01.00 201-2219-108-20080618) with ESMTP id <20090404190924.ONOJ771.viefep16-int.chello.at@edge05.upc.biz>; Sat, 4 Apr 2009 21:09:24 +0200 Received: from lizard.fafoe.narf.at ([213.47.85.26]) by edge05.upc.biz with edge id bX8f1b08c0a5KZh05X8gv8; Sat, 04 Apr 2009 21:09:24 +0200 X-SourceIP: 213.47.85.26 Received: by lizard.fafoe.narf.at (Postfix, from userid 1001) id 7E40BBAF0; Sat, 4 Apr 2009 21:08:39 +0200 (CEST) Date: Sat, 4 Apr 2009 21:08:39 +0200 From: Stefan Farfeleder To: Jilles Tjoelker Message-ID: <20090404190838.GA1352@lizard.fafoe.narf.at> Mail-Followup-To: Jilles Tjoelker , Wesley Shields , standards@freebsd.org References: <20090322144753.GA48259@atarininja.org> <20090322214741.GA50879@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090322214741.GA50879@stack.nl> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Wesley Shields , standards@freebsd.org Subject: Re: FW: shell choice freebsd git port X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 19:26:20 -0000 On Sun, Mar 22, 2009 at 10:47:41PM +0100, Jilles Tjoelker wrote: > On Sun, Mar 22, 2009 at 10:47:53AM -0400, Wesley Shields wrote: > > As the maintainer of devel/git I'd like this port to do the right thing, > > but I'm not sure if this is a legitimate bug in our /bin/sh or not. > > Anyone care to comment on this? > > > ----- Forwarded message from Jeff King ----- > > > Date: Sun, 22 Mar 2009 05:37:10 -0400 > > From: Jeff King > > To: wxs@freebsd.org > > Subject: shell choice freebsd git port > > > Hi, > > > I'm one of the upstream developers of git, and it looks like you are the > > git ports maintainer for FreeBSD. I wanted to discuss an issue which you > > may run into while packaging git 1.6.2.1. > > > It seems that FreeBSD's /bin/sh treats blank lines in an eval as a > > successful command. E.g., (the output is from FreeBSD 6.1, but I built > > the current HEAD from anoncvs and it seems to have the same problem): > > > $ /bin/sh > > $ eval 'false > > > > ' > > $ echo $? > > 0 > > > (whereas bash and dash would print '1'). > > > This is problematic for our test suite, which consists of a lot of > > eval'ing. Failing tests may be missed if their status is ignored, one > > test in 1.6.2.1 which expects a non-zero exit status actually does > > report failure when it actually succeeded. On top of that, some of the > > scripts (like bisect and filter-branch) care about the exit status of > > evals at run-time to determine whether an error occurred. > > > There is some discussion on the git list here: > > > http://thread.gmane.org/gmane.comp.version-control.git/112519/focus=112621 > > > I don't know if you want to do anything to the port to work around this. > > The obvious solution is requiring bash, and setting SHELL_PATH > > appropriately in the Makefile. You may also want to see if anyone is > > interested in treating this like a bug in /bin/sh and fixing it (I > > consider it a bug, but others may consider it historical behavior, I > > suppose). > > As discussed on IRC, I think this is a bug in /bin/sh. > > Just from reading the code, NetBSD does not seem to have fixed this. > > The following patch seems to fix the problem: > http://www.stack.nl/~jilles/unix/sh-eval-emptyline.patch > > Apart from 'eval', also 'trap', 'fc' and strings passed with '-c' are > affected. > > Empty lines inside {}, if or similar constructs are treated differently > and work fine even without the patch. Committed, thanks!