NetBSD Problem Report #44599

From www@NetBSD.org  Fri Feb 18 19:34:53 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 5F59863B11D
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 18 Feb 2011 19:34:53 +0000 (UTC)
Message-Id: <20110218193452.6F73763B100@www.NetBSD.org>
Date: Fri, 18 Feb 2011 19:34:52 +0000 (UTC)
From: steve.vernon@citrix.com
Reply-To: steve.vernon@citrix.com
To: gnats-bugs@NetBSD.org
Subject: libedit acts as if no data read if editmode is turned off
X-Send-Pr-Version: www-1.0

>Number:         44599
>Category:       lib
>Synopsis:       libedit acts as if no data read if editmode is turned off
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 18 19:35:00 +0000 2011
>Closed-Date:    Sun Nov 13 18:39:06 +0000 2011
>Last-Modified:  Sun Nov 13 18:39:06 +0000 2011
>Originator:     Steven Vernon
>Release:        sources as of 2011/02/04
>Organization:
Citrix
>Environment:
>Description:
If the terminal is detected as being non-interactive in readline emulation, the number of characters read is left as 0 and the el_gets function returns NULL.

The end result of this is that applications think that no data was read.

This can also be encountered if the application deliberately turns off edit mode.

>How-To-Repeat:
We got into this case when using Perl expect (*not* expect on the command line) talking via SSH to an application using libedit in its readline emulation. There are probably simpler use cases.

The bottom line is that libedit should be tested for non-interactive terminals.
>Fix:
In libedit/read.c there is code in FUN(el,gets) that handles the EDIT_DISABLED case. This mode is set automatically in readline.c (by doing "el_set(e, EL_EDITMODE, 0)") if the terminal is detected as being non-interactive. In this case the number of characters read is not updated - the value is stored in *nread. This causes the el_gets() routine to return NULL.

If you look earlier in the function, there is a very similar block of code for NO_TTY. In that case at the end of the block, it sets the cursor, lastchar, *cp, and *nread before going to "done". But the EDIT_DISABLED case does all that *except* for setting *nread - this line should be added to the EDIT_DISABLED case.

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44599 CVS commit: src/lib/libedit
Date: Fri, 18 Feb 2011 15:53:05 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Fri Feb 18 20:53:05 UTC 2011

 Modified Files:
 	src/lib/libedit: read.c

 Log Message:
 PR/44599: Steven Vernon: libedit acts as if no data read if editmode is turned
 off because nread is uninitialized in the edit disabled case.
 >Confidential:   no
 >Severity:       serious
 >Priority:       medium
 >Responsible:    lib-bug-people
 >State:          open
 >Class:          sw-bug
 >Submitter-Id:   net
 >Arrival-Date:   Fri Feb 18 19:35:00 +0000 2011
 >Release:        sources as of 2011/02/04
 >Organization:


 To generate a diff of this commit:
 cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/read.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 13 Nov 2011 18:39:06 +0000
State-Changed-Why:
Committed by Christos in February.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.