From nobody@FreeBSD.org  Sun Apr 28 14:40:20 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 0A7DE37B417
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 28 Apr 2002 14:40:20 -0700 (PDT)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g3SLeKA53232;
	Sun, 28 Apr 2002 14:40:20 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200204282140.g3SLeKA53232@freefall.freebsd.org>
Date: Sun, 28 Apr 2002 14:40:20 -0700 (PDT)
From: Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: libiconv run into endless loop during making security/gpgme.
X-Send-Pr-Version: www-1.0

>Number:         37543
>Category:       ports
>Synopsis:       libiconv run into endless loop during making security/gpgme.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gnome
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 28 14:50:03 PDT 2002
>Closed-Date:    Mon Apr 29 11:44:28 PDT 2002
>Last-Modified:  Mon Apr 29 11:44:28 PDT 2002
>Originator:     Fuyuhiko Maruyama
>Release:        FreeBSD 4.5-STABLE
>Organization:
Tokyo Institute of Technology
>Environment:
FreeBSD guns.private 4.5-STABLE FreeBSD 4.5-STABLE #1: Mon Apr 29 01:48:04 JST 2002     maruyama@guns.private:/usr/obj/usr/src/sys/GUNS  i386
    
>Description:
When libiconv fail text conversion, it may run into
endless loop (not always).

The problem is caused by libiconv's odd error handling. There 
is some program points where error code is silently changed,
RET_ILUNI to RET_TOOSMALL.  Since RET_TOOSMALL means no
sufficient buffer memory, libiconv try to enlarge buffer and
retry conversion.  Because of this nature, silently changed
error code causes endless loop of (enlarge buffer -> retry).
>How-To-Repeat:
1. setenv LANG ja_JP.eucJP
2. cd /usr/ports/gpgme
3. make

It may be a locale dependent problem and I only know it
appears when I set LANG=ja_JP.eucJP.

>Fix:
Although I met the problem when I make security/gpgme, the
actual problem is in converters/libiconv.

Here is a patch to fix libiconv.
I'm sorry to paste it from send-pr's web interface, I know
it breaks patch ;-<.

--- lib/loop_unicode.h.orig     Fri Jun  8 22:04:33 2001
+++ lib/loop_unicode.h  Mon Apr 29 05:12:08 2002
@@ -52,8 +52,7 @@
       cd->ostate = backup_state;
       outptr = backup_outptr;
       outleft = backup_outleft;
-      if (sub_outcount < 0)
-        return RET_TOOSMALL;
+      return sub_outcount;
     }
   }
   {
@@ -96,8 +95,7 @@
           cd->ostate = backup_state;
           outptr = backup_outptr;
           outleft = backup_outleft;
-          if (sub_outcount < 0)
-            return RET_TOOSMALL;
+         return sub_outcount;
         }
         if (last)
           break;
@@ -144,8 +142,7 @@
       cd->ostate = backup_state;
       outptr = backup_outptr;
       outleft = backup_outleft;
-      if (sub_outcount < 0)
-        return RET_TOOSMALL;
+      return sub_outcount;
     }
   }
   return RET_ILUNI;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: nork 
State-Changed-When: Mon Apr 29 08:19:17 PDT 2002 
State-Changed-Why:  
over to gnome maintiner. 


Responsible-Changed-From-To: freebsd-ports->gnome 
Responsible-Changed-By: nork 
Responsible-Changed-When: Mon Apr 29 08:19:17 PDT 2002 
Responsible-Changed-Why:  
over to gnome maintiner. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37543 

From: Norikatsu Shigemura <nork@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc: fuyuhik8@is.titech.ac.jp, freebsd-ports@FreeBSD.org,
	gnome@FreeBSD.org
Subject: Re: ports/37543: libiconv run into endless loop during making security/gpgme.
Date: Tue, 30 Apr 2002 01:01:13 +0900

 On Sun, 28 Apr 2002 14:40:20 -0700 (PDT)
 Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp> wrote:
 
 > Here is a patch to fix libiconv.
 > I'm sorry to paste it from send-pr's web interface, I know
 > it breaks patch ;-<.
 
 	I tested. This patch is OK.
State-Changed-From-To: analyzed->closed 
State-Changed-By: marcus 
State-Changed-When: Mon Apr 29 11:44:13 PDT 2002 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37543 
>Unformatted:
