From owner-freebsd-standards@FreeBSD.ORG Mon May 16 11:02:04 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5FC4316A4D8 for ; Mon, 16 May 2005 11:02:04 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 33DEC43D78 for ; Mon, 16 May 2005 11:02:04 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4GB22qQ021397 for ; Mon, 16 May 2005 11:02:02 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4GB216X021386 for freebsd-standards@freebsd.org; Mon, 16 May 2005 11:02:01 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 16 May 2005 11:02:01 GMT Message-Id: <200505161102.j4GB216X021386@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2005 11:02:04 -0000 Current FreeBSD problem reports Critical problems Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/03/05] bin/25542 standards /bin/sh: null char in quoted string p [2002/02/25] standards/35307standards standard include files are not standard c o [2002/12/13] kern/46239 standards posix semaphore implementation errors o [2003/04/21] standards/51209standards [PATCH] add a64l()/l64a/l64a_r functions p [2003/06/05] standards/52972standards /bin/sh arithmetic not POSIX compliant o [2003/07/12] standards/54410standards one-true-awk not POSIX compliant (no exte o [2004/01/01] standards/60772standards _Bool and bool should be unsigned o [2004/11/03] standards/73500standards 'set +o' in /bin/sh does not include unse o [2005/03/03] standards/78357standards getaddrinfo() doesn't appear to support A o [2005/03/09] standards/78650standards ttyname_r() is not standards compliant o [2005/03/16] standards/78907standards does not define pthread typ 11 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/09/24] bin/21519 standards sys/dir.h should be deprecated some more o [2001/01/16] bin/24390 standards Replacing old dir-symlinks when using /bi s [2001/01/24] standards/24590standards timezone function not compatible witn Sin s [2001/06/18] kern/28260 standards UIO_MAXIOV needs to be made public p [2001/11/20] standards/32126standards getopt(3) not Unix-98 conformant o [2002/02/27] misc/35381 standards incorrect floating-point display of large s [2002/03/19] standards/36076standards Implementation of POSIX fuser command o [2002/06/14] standards/39256standards [v]snprintf aren't POSIX-conformant for s o [2002/07/09] kern/40378 standards stdlib.h gives needless warnings with -an p [2002/08/12] standards/41576standards POSIX compliance of ln(1) o [2002/10/23] standards/44425standards getcwd() succeeds even if current dir has o [2002/12/09] standards/46119standards Priority problems for SCHED_OTHER using p o [2003/07/24] standards/54809standards pcvt deficits o [2003/07/25] standards/54833standards more pcvt deficits o [2003/07/25] standards/54839standards pcvt deficits o [2003/07/31] standards/55112standards glob.h, glob_t's gl_pathc should be "size o [2003/09/05] standards/56476standards cd9660 unicode support simple hack o [2003/10/29] standards/58676standards grantpt(3) alters storage used by ptsname p [2003/12/26] standards/60597standards FreeBSD's /usr/include lacks of cpio.h s [2004/02/14] standards/62858standards malloc(0) not C99 compliant p [2004/02/21] standards/63173standards Patch to add getopt_long_only(3) to libc o [2004/03/29] kern/64875 standards [patch] add a system call: fdatasync() o [2004/05/07] standards/66357standards make POSIX conformance problem ('sh -e' & o [2004/05/11] standards/66531standards _gettemp uses a far smaller set of filena o [2004/08/22] standards/70813standards [PATCH] ls not Posix compliant o [2004/08/26] docs/70985 standards [patch] sh(1): incomplete documentation o o [2004/09/22] standards/72006standards floating point formating in non-C locales o [2005/03/20] standards/79055standards Add an IFS regression test for shells o [2005/03/20] standards/79056standards regex(3) regression tests o [2005/03/21] standards/79067standards /bin/sh should be more intelligent about 30 problems total. From owner-freebsd-standards@FreeBSD.ORG Thu May 19 03:20:02 2005 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B961A16A4CE for ; Thu, 19 May 2005 03:20:02 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2297843D7C for ; Thu, 19 May 2005 03:20:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4J3K1T2007252 for ; Thu, 19 May 2005 03:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4J3K1ck007251; Thu, 19 May 2005 03:20:01 GMT (envelope-from gnats) Resent-Date: Thu, 19 May 2005 03:20:01 GMT Resent-Message-Id: <200505190320.j4J3K1ck007251@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, Olivier Nicole Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 52CF816A4CE for ; Thu, 19 May 2005 03:12:55 +0000 (GMT) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3BE443DAC for ; Thu, 19 May 2005 03:12:50 +0000 (GMT) (envelope-from on@cs.ait.ac.th) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) by mail.cs.ait.ac.th (8.12.11/8.12.11) with ESMTP id j4J3CkfH067045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 19 May 2005 10:12:46 +0700 (ICT) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.13.1/8.12.11) id j4J3CjiK074074; Thu, 19 May 2005 10:12:45 +0700 (ICT) Message-Id: <200505190312.j4J3CjiK074074@banyan.cs.ait.ac.th> Date: Thu, 19 May 2005 10:12:45 +0700 (ICT) From: Olivier Nicole To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/81237: missing magic.h include with libmagic X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Olivier Nicole List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2005 03:20:02 -0000 >Number: 81237 >Category: standards >Synopsis: missing magic.h include with libmagic >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 19 03:20:01 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Olivier Nicole >Release: FreeBSD 5.3-RELEASE-p6 i386; 5.3-RELEASE-p15 i386; 5.3-RELEASE-p14 amd64 >Organization: Asian Institue of technology >Environment: System: FreeBSD .cs.ait.ac.th 5.3-RELEASE-p6 FreeBSD 5.3-RELEASE-p6 #2: Tue Mar 29 10:00:42 ICT 2005 .cs.ait.ac.th:/usr/obj/usr/src/sys/SMALL i386 FreeBSD cs.ait.ac.th 5.3-RELEASE-p15 FreeBSD 5.3-RELEASE-p15 #2: Fri May 13 12:07:45 ICT 2005 cs.ait.ac.th:/usr/obj/usr/src/sys/GENERIC i386 FreeBSD xxx.net 5.3-RELEASE-p14 FreeBSD 5.3-RELEASE-p14 #4: Wed May 11 08:35:02 CEST 2005 xxx.net:/usr/obj/usr/src/sys/OMC amd64 >Description: man libmagic says #include but there is no such magic.h in /usr/include Among other things, it breaks the port of /usr/ports/sysutils/pecl-fileinfo/ >How-To-Repeat: Any 5.3 that I can see (2 arch and 3 release level) >Fix: >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Thu May 19 10:16:18 2005 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E98B616A4CE; Thu, 19 May 2005 10:16:18 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C54E43DA0; Thu, 19 May 2005 10:16:18 +0000 (GMT) (envelope-from keramida@FreeBSD.org) Received: from freefall.freebsd.org (keramida@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4JAGIsR094054; Thu, 19 May 2005 10:16:18 GMT (envelope-from keramida@freefall.freebsd.org) Received: (from keramida@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4JAGIoX094050; Thu, 19 May 2005 10:16:18 GMT (envelope-from keramida) Date: Thu, 19 May 2005 10:16:18 GMT From: Giorgos Keramidas Message-Id: <200505191016.j4JAGIoX094050@freefall.freebsd.org> To: keramida@FreeBSD.org, freebsd-standards@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: misc/81237: missing magic.h include with libmagic X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2005 10:16:19 -0000 Synopsis: missing magic.h include with libmagic Responsible-Changed-From-To: freebsd-standards->freebsd-bugs Responsible-Changed-By: keramida Responsible-Changed-When: Thu May 19 10:15:24 GMT 2005 Responsible-Changed-Why: Refile under misc/. This is not a standards compliance problem. http://www.freebsd.org/cgi/query-pr.cgi?pr=81237 From owner-freebsd-standards@FreeBSD.ORG Fri May 20 02:50:08 2005 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2552116A4CE for ; Fri, 20 May 2005 02:50:08 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 965C943D86 for ; Fri, 20 May 2005 02:50:07 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4K2o7oP018748 for ; Fri, 20 May 2005 02:50:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4K2o7KC018747; Fri, 20 May 2005 02:50:07 GMT (envelope-from gnats) Resent-Date: Fri, 20 May 2005 02:50:07 GMT Resent-Message-Id: <200505200250.j4K2o7KC018747@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, Rostislav Krasny Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B46BE16A4CE for ; Fri, 20 May 2005 02:45:49 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A7AB43DB6 for ; Fri, 20 May 2005 02:45:49 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j4K2jnoP058203 for ; Fri, 20 May 2005 02:45:49 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j4K2jnql058202; Fri, 20 May 2005 02:45:49 GMT (envelope-from nobody) Message-Id: <200505200245.j4K2jnql058202@www.freebsd.org> Date: Fri, 20 May 2005 02:45:49 GMT From: Rostislav Krasny To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: standards/81287: [PATCH]: fingerd(8) might send a line not ending in CRLF X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2005 02:50:08 -0000 >Number: 81287 >Category: standards >Synopsis: [PATCH]: fingerd(8) might send a line not ending in CRLF >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 May 20 02:50:07 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Rostislav Krasny >Release: FreeBSD 5.4-RELEASE >Organization: >Environment: FreeBSD mercury 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 00:55:11 IDT 2005 root@mercury:/usr/obj/usr/src/sys/MYKERNEL i386 >Description: According to RFC1288: 2.2. Data format Any data transferred MUST be in ASCII format, with no parity, and with lines ending in CRLF (ASCII 13 followed by ASCII 10). This excludes other character formats such as EBCDIC, etc. This also means that any characters between ASCII 128 and ASCII 255 should truly be international data, not 7-bit ASCII with the parity bit set. But fingerd(8) sends some specific lines not ending in CRLF. These specific lines in the code are: "must provide username\r\n" "forwarding service denied\r\n" Although the strings are ending in CRLF the fingerd(8) adds an extra '\n' character to the end during a transmission. >How-To-Repeat: enable 'fingerd -s' or 'fingerd -s -l' in /etc/inetd.conf start or restart the inetd(8) daemon run 'nc -v 127.0.0.1 79' and press [Enter] when connected run 'nc -v 127.0.0.1 79' and press [@] and then [Enter] when connected In both cases you will get an extra '\n' character in the output. >Fix: The simple fix is just replacing all puts() functions to fputs() functions. But I made a much better patch that also fixes several other little problems and also simplifies the code. See my explanations after the patch. diff -ur fingerd.orig/fingerd.c /usr/src/libexec/fingerd/fingerd.c --- fingerd.orig/fingerd.c Thu May 12 17:58:29 2005 +++ /usr/src/libexec/fingerd/fingerd.c Fri May 20 04:14:04 2005 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -103,18 +104,15 @@ { int one = 1; if (setsockopt(STDOUT_FILENO, IPPROTO_TCP, TCP_NOPUSH, &one, - sizeof one) < 0) { - logerr("setsockopt(TCP_NOPUSH) failed: %m"); + sizeof one) == -1) { + logerr("setsockopt(TCP_NOPUSH): %m"); } } - if (!fgets(line, sizeof(line), stdin)) - exit(1); - if (logging || pflag) { sval = sizeof(ss); - if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0) - logerr("getpeername: %s", strerror(errno)); + if (getpeername(0, (struct sockaddr *)&ss, &sval) == -1) + logerr("getpeername(): %m"); realhostname_sa(rhost, sizeof rhost - 1, (struct sockaddr *)&ss, sval); rhost[sizeof(rhost) - 1] = '\0'; @@ -122,40 +120,24 @@ setenv("FINGERD_REMOTE_HOST", rhost, 1); } - if (logging) { - char *t; - char *end; - - end = memchr(line, 0, sizeof(line)); - if (end == NULL) { - if ((t = malloc(sizeof(line) + 1)) == NULL) - logerr("malloc: %s", strerror(errno)); - memcpy(t, line, sizeof(line)); - t[sizeof(line)] = 0; - } else { - if ((t = strdup(line)) == NULL) - logerr("strdup: %s", strerror(errno)); - } - for (end = t; *end; end++) - if (*end == '\n' || *end == '\r') - *end = ' '; - syslog(LOG_NOTICE, "query from %s: `%s'", rhost, t); + if (!fgets(line, sizeof(line), stdin)) { + if (logging) + syslog(LOG_NOTICE, "no query from %s", rhost); + exit(0); } + line[strcspn(line, "\r\n")] = '\0'; + + if (logging) + syslog(LOG_NOTICE, "query from %s: `%s'", rhost, line); comp = &av[1]; av[2] = "--"; - for (lp = line, ap = &av[3];;) { - *ap = strtok(lp, " \t\r\n"); - if (!*ap) { - if (secure && ap == &av[3]) { - puts("must provide username\r\n"); - exit(1); - } - break; - } + ap = &av[3]; + *ap = strtok(line, " \t"); + while (*ap != NULL) { if (secure && strchr(*ap, '@')) { - puts("forwarding service denied\r\n"); - exit(1); + fputs("forwarding service denied\r\n", stdout); + exit(0); } /* RFC742: "/[Ww]" == "-l" */ @@ -167,15 +149,20 @@ *ap = NULL; break; } - lp = NULL; + *ap = strtok(NULL, " \t"); + } + if (secure && ap == &av[3]) { + fputs("must provide username\r\n", stdout); + exit(0); } if ((lp = strrchr(prog, '/')) != NULL) *comp = ++lp; else *comp = prog; - if (pipe(p) < 0) - logerr("pipe: %s", strerror(errno)); + + if (pipe(p) == -1) + logerr("pipe(): %m"); switch(vfork()) { case 0: @@ -191,18 +178,21 @@ #define MSG ": cannot execute\n" write(STDERR_FILENO, MSG, strlen(MSG)); #undef MSG + syslog(LOG_ERR, "execv(\"%s\"): %m", prog); _exit(1); case -1: - logerr("fork: %s", strerror(errno)); + logerr("vfork(): %m"); } (void)close(p[1]); if (!(fp = fdopen(p[0], "r"))) - logerr("fdopen: %s", strerror(errno)); + logerr("fdopen(): %m"); while ((ch = getc(fp)) != EOF) { if (ch == '\n') putchar('\r'); putchar(ch); } + + wait(NULL); exit(0); } @@ -216,5 +206,5 @@ (void)vsyslog(LOG_ERR, fmt, ap); va_end(ap); exit(1); - /* NOTREACHED */ + /* NOT REACHED */ } 1. fgets() reads the input after we know the peer's address and even if no data was received we can log the address 2. fgets() always terminates the string with a null byte, so the memchr()/memcpy()/malloc() code is needless 3. reterminate the string, so it will not have any '\r' '\n' char and don't add spaces, so the query in the log will be real 4. use a %m for logging instead of %s and strerror(errno) 5. simplify the query parsing and other code 6. log a failure of execv() if occured >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Sat May 21 19:36:10 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3A7C416A4CF for ; Sat, 21 May 2005 19:36:10 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 38F9A43D68 for ; Sat, 21 May 2005 19:36:06 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) j4LJa5bJ060389 for ; Sat, 21 May 2005 12:36:05 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost)j4LJa5wV060388 for freebsd-standards@freebsd.org; Sat, 21 May 2005 12:36:05 -0700 (PDT) (envelope-from sgk) Date: Sat, 21 May 2005 12:36:05 -0700 From: Steve Kargl To: freebsd-standards@freebsd.org Message-ID: <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 19:36:10 -0000 >From http://www.opengroup.org/onlinepubs/009695399/toc.htm /dev/null -- An infinite data source and data sink. Data written to /dev/null shall be discarded. Reads from /dev/null shall always return end-of-file (EOF). This program #include int main(void) { int i=0,j; FILE *fp; fp = fopen("/dev/null", "r"); while(fread(&j, sizeof(int), 1, fp) != 1) { i++; if (i == 5) break; } printf("i = %d\n", i); if (j == EOF) printf("EOF\n"); else printf("j = %d\n", j); } prints i = 5 j = 1 Is this historic BSD defacto behavior? -- Steve From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:14:47 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE20016A568 for ; Sat, 21 May 2005 20:14:47 +0000 (GMT) Received: from gidgate.gid.co.uk (gid.co.uk [194.32.164.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4FA6F43D55 for ; Sat, 21 May 2005 20:14:46 +0000 (GMT) (envelope-from rb@gid.co.uk) Received: (from rb@localhost) by gidgate.gid.co.uk (8.11.7/8.11.6) id j4LKEj414941; Sat, 21 May 2005 21:14:45 +0100 (BST) (envelope-from rb) Message-Id: <6.2.0.14.2.20050521211303.04837368@gid.co.uk> X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14 Date: Sat, 21 May 2005 21:14:34 +0100 To: Steve Kargl , freebsd-standards@freebsd.org From: Bob Bishop In-Reply-To: <20050521193605.GB51782@troutmask.apl.washington.edu> References: <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:14:48 -0000 At 20:36 21/05/2005, Steve Kargl wrote: > >From http://www.opengroup.org/onlinepubs/009695399/toc.htm > > /dev/null -- An infinite data source and data sink. Data > written to /dev/null shall be discarded. Reads from > /dev/null shall always return end-of-file (EOF). > >This program > > #include > int main(void) { > int i=0,j; > FILE *fp; > fp = fopen("/dev/null", "r"); > while(fread(&j, sizeof(int), 1, fp) != 1) { > i++; > if (i == 5) break; > } > printf("i = %d\n", i); > if (j == EOF) > printf("EOF\n"); > else > printf("j = %d\n", j); >} > >prints > >i = 5 >j = 1 > >Is this historic BSD defacto behavior? When fread hits EOF, it doesn't write to j. -- Bob Bishop +44 (0)118 940 1243 rb@gid.co.uk fax +44 (0)118 940 1295 From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:15:08 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0307016A4CE for ; Sat, 21 May 2005 20:15:08 +0000 (GMT) Received: from storm.uk.FreeBSD.org (storm.uk.FreeBSD.org [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D6D543D55 for ; Sat, 21 May 2005 20:15:07 +0000 (GMT) (envelope-from mark@grondar.org) Received: from storm.uk.FreeBSD.org (uucp@localhost [127.0.0.1]) by storm.uk.FreeBSD.org (8.13.3/8.13.3) with ESMTP id j4LKF5XA029943; Sat, 21 May 2005 21:15:05 +0100 (BST) (envelope-from mark@grondar.org) Received: (from uucp@localhost)j4LKF3hS029939; Sat, 21 May 2005 21:15:03 +0100 (BST) (envelope-from mark@grondar.org) Received: from grondar.org (localhost [127.0.0.1]) by grovel.grondar.org (8.13.3/8.13.1) with ESMTP id j4LKDTMC070728; Sat, 21 May 2005 21:13:29 +0100 (BST) (envelope-from mark@grondar.org) Message-Id: <200505212013.j4LKDTMC070728@grovel.grondar.org> X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.0.4 To: Steve Kargl From: Mark Murray In-Reply-To: Your message of "Sat, 21 May 2005 12:36:05 PDT." <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 21 May 2005 21:13:29 +0100 Sender: mark@grondar.org cc: freebsd-standards@FreeBSD.ORG Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:15:08 -0000 Steve Kargl writes: > >From http://www.opengroup.org/onlinepubs/009695399/toc.htm > > /dev/null -- An infinite data source and data sink. Data > written to /dev/null shall be discarded. Reads from > /dev/null shall always return end-of-file (EOF). > > This program ... abuses fread(3) return values. Try this: [grovel] ~ 09:10 pm $ cat test.c #include int main(void) { int i, j; FILE *fp; j = -1; fp = fopen("/dev/null", "r"); while((i = fread(&j, sizeof(int), 1, fp))) { printf("i = %d\nj = %d\n", i, j); if (feof(fp)) break; } printf("AT END\ni = %d\nj = %d\n", i, j); return 0; } [grovel] ~ 09:10 pm $ gcc -Wall test.c -o test [grovel] ~ 09:11 pm $ ./test AT END i = 0 j = -1 [grovel] ~ 09:11 pm $ M -- Mark Murray iumop ap!sdn w,I idlaH From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:32:09 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CCF4516A4CE; Sat, 21 May 2005 20:32:09 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C3F343D49; Sat, 21 May 2005 20:32:09 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) j4LKW9Di060685; Sat, 21 May 2005 13:32:09 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost)j4LKW9Hu060684; Sat, 21 May 2005 13:32:09 -0700 (PDT) (envelope-from sgk) Date: Sat, 21 May 2005 13:32:09 -0700 From: Steve Kargl To: Mark Murray Message-ID: <20050521203209.GA60647@troutmask.apl.washington.edu> References: <20050521193605.GB51782@troutmask.apl.washington.edu> <200505212013.j4LKDTMC070728@grovel.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505212013.j4LKDTMC070728@grovel.grondar.org> User-Agent: Mutt/1.4.2.1i cc: freebsd-standards@FreeBSD.ORG Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:32:10 -0000 On Sat, May 21, 2005 at 09:13:29PM +0100, Mark Murray wrote: > Steve Kargl writes: > > >From http://www.opengroup.org/onlinepubs/009695399/toc.htm > > > > /dev/null -- An infinite data source and data sink. Data > > written to /dev/null shall be discarded. Reads from > > /dev/null shall always return end-of-file (EOF). > > > > This program > > ... abuses fread(3) return values. > Sorry for the noise. I remembered feof() about 15 minutes ago. FreeBSD's null(4) man page, although quite short, is somewhat confusing in its vagueness. -- Steve From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:45:06 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E453316A4CE for ; Sat, 21 May 2005 20:45:06 +0000 (GMT) Received: from storm.uk.FreeBSD.org (storm.uk.FreeBSD.org [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D36D43D48 for ; Sat, 21 May 2005 20:45:06 +0000 (GMT) (envelope-from mark@grondar.org) Received: from storm.uk.FreeBSD.org (uucp@localhost [127.0.0.1]) by storm.uk.FreeBSD.org (8.13.3/8.13.3) with ESMTP id j4LKj411030311; Sat, 21 May 2005 21:45:04 +0100 (BST) (envelope-from mark@grondar.org) Received: (from uucp@localhost)j4LKj34n030310; Sat, 21 May 2005 21:45:03 +0100 (BST) (envelope-from mark@grondar.org) Received: from grondar.org (localhost [127.0.0.1]) by grovel.grondar.org (8.13.3/8.13.1) with ESMTP id j4LKgk8i071299; Sat, 21 May 2005 21:42:47 +0100 (BST) (envelope-from mark@grondar.org) Message-Id: <200505212042.j4LKgk8i071299@grovel.grondar.org> X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.0.4 To: Steve Kargl From: Mark Murray In-Reply-To: Your message of "Sat, 21 May 2005 13:32:09 PDT." <20050521203209.GA60647@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 21 May 2005 21:42:46 +0100 Sender: mark@grondar.org cc: freebsd-standards@FreeBSD.ORG Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:45:07 -0000 Steve Kargl writes: > Sorry for the noise. I remembered feof() about 15 minutes > ago. FreeBSD's null(4) man page, although quite short, is > somewhat confusing in its vagueness. NP. If the docs don't work, I guess we need to fix them. Given that I've had my grimy paws in null(4), it seems fair that I fix the docs. I'll give them a general looking over, but if you have any suggestions you'd like to see put in there, I'd be happy to oblige. M -- Mark Murray iumop ap!sdn w,I idlaH From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:52:29 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 12F6C16A4CE for ; Sat, 21 May 2005 20:52:29 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 696D643D1F for ; Sat, 21 May 2005 20:52:28 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) j4LKqQAX003339; Sat, 21 May 2005 23:52:26 +0300 Received: from gothmog.gr (patr530-a033.otenet.gr [212.205.215.33]) j4LKoZNq014454; Sat, 21 May 2005 23:50:36 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.3/8.13.3) with ESMTP id j4LKqMix001516; Sat, 21 May 2005 23:52:22 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.13.3/8.13.3/Submit) id j4LKqMEH001515; Sat, 21 May 2005 23:52:22 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Sat, 21 May 2005 23:52:22 +0300 From: Giorgos Keramidas To: Steve Kargl Message-ID: <20050521205222.GA1014@gothmog.gr> References: <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050521193605.GB51782@troutmask.apl.washington.edu> cc: freebsd-standards@freebsd.org Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:52:29 -0000 On 2005-05-21 12:36, Steve Kargl wrote: > >From http://www.opengroup.org/onlinepubs/009695399/toc.htm > > /dev/null -- An infinite data source and data sink. Data > written to /dev/null shall be discarded. Reads from > /dev/null shall always return end-of-file (EOF). > > This program > > #include > int main(void) { > int i=0,j; > FILE *fp; > fp = fopen("/dev/null", "r"); > while(fread(&j, sizeof(int), 1, fp) != 1) { > i++; > if (i == 5) break; > } The condition of the while loop above is bogus. fread() of any amount of data from /dev/null returns 0 items, but the loop will still iterate, increasing i as if some data was read. Rewriting the loop as shown below reveals that /dev/null indeed works as expected: for (i = 0; fread(&j, sizeof(j), 1, fp) == 1; i++) printf("step %d read %lu bytes\n", i, (unsigned long)sizeof(j)); This *NEVER* prints a "step X read Y bytes" message from /dev/null. > if (j == EOF) > printf("EOF\n"); > else > printf("j = %d\n", j); This is bogus. fread() doesn't set the output buffer to EOF but marks the `fp' stream as end-of-file'd. The correct way to check for end-of-file on stdio.h streams is: if (feof(fp)) ... ; From owner-freebsd-standards@FreeBSD.ORG Sat May 21 21:03:10 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62AA916A4CE; Sat, 21 May 2005 21:03:10 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 326A043D1D; Sat, 21 May 2005 21:03:10 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) j4LL39EM060877; Sat, 21 May 2005 14:03:09 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost)j4LL39b0060876; Sat, 21 May 2005 14:03:09 -0700 (PDT) (envelope-from sgk) Date: Sat, 21 May 2005 14:03:09 -0700 From: Steve Kargl To: Mark Murray Message-ID: <20050521210309.GA60844@troutmask.apl.washington.edu> References: <20050521203209.GA60647@troutmask.apl.washington.edu> <200505212042.j4LKgk8i071299@grovel.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505212042.j4LKgk8i071299@grovel.grondar.org> User-Agent: Mutt/1.4.2.1i cc: freebsd-standards@FreeBSD.ORG Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 21:03:10 -0000 On Sat, May 21, 2005 at 09:42:46PM +0100, Mark Murray wrote: > Steve Kargl writes: > > Sorry for the noise. I remembered feof() about 15 minutes > > ago. FreeBSD's null(4) man page, although quite short, is > > somewhat confusing in its vagueness. > > NP. If the docs don't work, I guess we need to fix them. Given that > I've had my grimy paws in null(4), it seems fair that I fix the docs. > > I'll give them a general looking over, but if you have any suggestions > you'd like to see put in there, I'd be happy to oblige. > I have to run to a little league baseball game, so I think about there. Something along the lines: The null device has permission 666. Upon writing to /dev/null, the data is thrown away. Upon reading /dev/null, it will always return EOF. -- Steve