NetBSD Problem Report #44858

From www@NetBSD.org  Tue Apr 12 05:35:35 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 D31F163C242
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 12 Apr 2011 05:35:35 +0000 (UTC)
Message-Id: <20110412053534.E24EA63BA68@www.NetBSD.org>
Date: Tue, 12 Apr 2011 05:35:34 +0000 (UTC)
From: anoop.rawat@citrix.com
Reply-To: anoop.rawat@citrix.com
To: gnats-bugs@NetBSD.org
Subject: CLI fails for the first time if the input character length is greater than 1024. From next time onwards it passes.
X-Send-Pr-Version: www-1.0

>Number:         44858
>Category:       lib
>Synopsis:       CLI fails for the first time if the input character length is greater than 1024. From next time onwards it passes.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    christos
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 12 05:40:00 +0000 2011
>Last-Modified:  Tue Apr 12 05:50:18 +0000 2011
>Originator:     Anoop
>Release:        the one which supports utf-8 chars.
>Organization:
Citrix
>Environment:
FreeBSD BLR3V-02 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Wed Jan 16 04:18:52 UTC 2008     root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
If i enter a CLI whose length is more than 1024 chars, it fails for the first time. From next time onwards it gracefully accepts that CLI.
This bug is in the netbsd version which supports UTF-8 chars.

The bug is in file chartype.c 


>How-To-Repeat:
enter the CLI whose length is greater than 1024 chars. 
For the first time it'll fail.
>Fix:
The bug is in file chartype.c 

SNIP
----

ct_encode_string(const Char *s, ct_buffer_t *conv)
{
	dst = conv->cbuff;
	while (*s) {
		used = ct_encode_char(dst, (int)(conv->csize -
		    (dst - conv->cbuff)), *s);
		if (used == -1) { /* failed to encode, need more buffer space */
			used = dst - conv->cbuff;
			ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, 0);
			if (!conv->cbuff)
				return NULL;
///anoop: Here dst pointer is incremented.
			dst = conv->cbuff + used;
			/* don't increment s here - we want to retry it! */
		}
		else
			++s;
///anoop: dst pointer incremented again moving to wrong offset.
		dst += used;
	}
	*dst = '\0';
	return conv->cbuff;
}
------

A simple Fix is to modify else statement:
else {
     ++s;
     dst = conv->cbuff + used;
}

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->christos
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Tue, 12 Apr 2011 05:50:18 +0000
Responsible-Changed-Why:
I think he is talking about libedit - christos knows that from inside out


>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.