Date: Mon, 26 Jun 2000 15:58:42 -0400 (EDT) From: adrian@ubergeeks.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/19532: cdcontrol does not handle EOF on stdin properly (patch included) Message-ID: <200006261958.PAA00788@cluebie.esolstice.int>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006261958.PAA00788>