From wosch@mail.cs.tu-berlin.de  Sat Aug 12 15:54:38 1995
Received: from who.cdrom.com (who.cdrom.com [192.216.222.3])
          by freefall.FreeBSD.org (8.6.11/8.6.6) with ESMTP id PAA25264
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 12 Aug 1995 15:54:37 -0700
Received: from mail.cs.tu-berlin.de (mail.cs.tu-berlin.de [130.149.17.13])
          by who.cdrom.com (8.6.11/8.6.11) with ESMTP id PAA11731
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 12 Aug 1995 15:54:29 -0700
Received: from localhost.cs.tu-berlin.de ([130.149.1.128]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id AAA15426 for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Aug 1995 00:50:58 +0200
Received: (from wosch@localhost) by localhost (8.6.9/8.6.9) id AAA01206; Sun, 13 Aug 1995 00:46:18 +0200
Message-Id: <199508122246.AAA01206@localhost>
Date: Sun, 13 Aug 1995 00:46:18 +0200
From: Wolfram Schneider <wosch@cs.tu-berlin.de>
Reply-To: wosch@cs.tu-berlin.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: head(1) ignore EOF
X-Send-Pr-Version: 3.2

>Number:         678
>Category:       bin
>Synopsis:       head(1) ignore EOF
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 12 16:00:01 PDT 1995
>Closed-Date:    Tue Aug 15 21:34:11 MET DST 1995
>Last-Modified:  Tue Nov 27 19:31:03 PST 2001
>Originator:     Wolfram Schneider
>Release:        FreeBSD 2.0-ALPHA i386
>Organization:
>Environment:


>Description:

	head(1) ignore EOF

>How-To-Repeat:

	$ echo "one line" > /tmp/foo
	$ head -100000000000 /tmp/foo
	^C


>Fix:
	
--- 1.1	1995/08/12 22:14:38
+++ head.c	1995/08/12 22:18:58
@@ -113,12 +113,11 @@
 {
 	register int ch;
 
-	while (cnt--)
-		while ((ch = getc(fp)) != EOF) {
+	while ((ch = getc(fp)) != EOF && cnt) {
 			if (putchar(ch) == EOF)
 				err(1, "stdout: %s", strerror(errno));
 			if (ch == '\n')
-				break;
+			cnt--;
 		}
 }
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Tue Aug 15 21:34:11 MET DST 1995 
State-Changed-Why:  
Suggested fix applied in head.c, rev 1.2. 

>Unformatted:
 
