From owner-freebsd-bugs Fri Oct 9 01:50:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA23460 for freebsd-bugs-outgoing; Fri, 9 Oct 1998 01:50:06 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA23440 for ; Fri, 9 Oct 1998 01:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id BAA28178; Fri, 9 Oct 1998 01:50:01 -0700 (PDT) Received: from ns.kf.mnc.waseda.ac.jp (ns.kf.mnc.waseda.ac.jp [133.9.10.98]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA23346 for ; Fri, 9 Oct 1998 01:49:17 -0700 (PDT) (envelope-from fujimoto@ns.kf.mnc.waseda.ac.jp) Received: (from fujimoto@localhost) by ns.kf.mnc.waseda.ac.jp (8.8.8/3.6Wbeta5/970731) id RAA27839; Fri, 9 Oct 1998 17:49:10 +0900 (JST) Message-Id: <199810090849.RAA27839@ns.kf.mnc.waseda.ac.jp> Date: Fri, 9 Oct 1998 17:49:10 +0900 (JST) From: fujimoto@oscar.elec.waseda.ac.jp Reply-To: fujimoto@oscar.elec.waseda.ac.jp To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/8225: /usr/bin/head -c never exit for short inputs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8225 >Category: bin >Synopsis: /usr/bin/head -c never exit for short inputs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 9 01:50:00 PDT 1998 >Last-Modified: >Originator: FUJIMOTO Kensaku >Organization: Waseda University >Release: FreeBSD 2.2.7-RELEASE i386 >Environment: FreeBSD /usr/bin/head with "-c" option has this bug. FreeBSD 2.2.7-RELEASE and FreeBSD-current also contain it. >Description: "head -c " never exit and loops forever (until it is killed), if the input stream has fewer bytes than specified (n). >How-To-Repeat: echo abc | head -c 10 >Fix: Please apply the patch below: --- ../ORIG/head/head.c Mon Sep 15 17:17:20 1997 +++ head.c Fri Oct 9 17:10:04 1998 @@ -155,7 +155,7 @@ else readlen = sizeof(buf); readlen = fread(buf, sizeof(char), readlen, fp); - if (readlen == EOF) + if (readlen == 0) break; if (fwrite(buf, sizeof(char), readlen, stdout) != readlen) err(1, "stdout"); >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message