From owner-freebsd-bugs Mon Jun 26 13: 0: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id AEA6237BCDA for ; Mon, 26 Jun 2000 13:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id NAA01528; Mon, 26 Jun 2000 13:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from esummer.esolstice.com (esummer.esolstice.com [209.145.65.15]) by hub.freebsd.org (Postfix) with ESMTP id 0C38637B942 for ; Mon, 26 Jun 2000 12:55:48 -0700 (PDT) (envelope-from adrian@mail.esolstice.com) Received: from cluebie.esolstice.int (an-fw.esolstice.com [208.241.63.212]) by esummer.esolstice.com (8.9.3/8.9.3) with ESMTP id PAA23219 for ; Mon, 26 Jun 2000 15:58:47 -0400 (EDT) (envelope-from adrian@mail.esolstice.com) Received: (from adrian@localhost) by cluebie.esolstice.int (8.9.3/8.9.3) id PAA00788; Mon, 26 Jun 2000 15:58:42 -0400 (EDT) (envelope-from adrian@mail.esolstice.com) Message-Id: <200006261958.PAA00788@cluebie.esolstice.int> Date: Mon, 26 Jun 2000 15:58:42 -0400 (EDT) From: adrian@ubergeeks.com Reply-To: adrian@ubergeeks.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/19532: cdcontrol does not handle EOF on stdin properly (patch included) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19532 >Category: bin >Synopsis: cdcontrol does not handle EOF on stdin properly >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: Mon Jun 26 13:00:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Adrian Filipi-Martin >Release: FreeBSD 4.0-STABLE i386 >Organization: Ubergeeks Consulting >Environment: 4-stable-062600 >Description: cdcontrol reprompts the user when EOF is seen on stdin and does not exit. >How-To-Repeat: Run cdcontrol and press your tty EOF character, usually ^D, a few times. You will see something like the following: # cdcontrol Compact Disc Control utility, version 2.0 Type `?' for command list cdcontrol> cdcontrol> cdcontrol> >Fix: Apply the following patch. The semantics of the value returned by the input() function are not defined since the return value is not used. I changed it to return values that are equivalent to the user typing the "quit" command when EOF is seen. EOF is assummed when either fgets() or el_gets() fail. --- cdcontrol.c.orig Mon Jun 26 15:18:55 2000 +++ cdcontrol.c Mon Jun 26 15:48:59 2000 @@ -956,8 +956,11 @@ el_set(el, EL_SIGNAL, 1); el_source(el, NULL); } - if ((bp = el_gets(el, &num)) == NULL || num == 0) - return (0); + if ((bp = el_gets(el, &num)) == NULL || num == 0) { + *cmd = CMD_QUIT; + fprintf (stderr, "\r\n"); + return (""); + } len = (num > MAXLINE) ? MAXLINE : num; memcpy(buf, bp, len); @@ -969,7 +972,7 @@ if (! fgets (buf, sizeof (buf), stdin)) { *cmd = CMD_QUIT; fprintf (stderr, "\r\n"); - return (0); + return (""); } } p = parse (buf, cmd); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message