Subject: lib/31874: iconv(3) return error when src string end with shift sequence.
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <obata@lins.jp>
List: netbsd-bugs
Date: 10/20/2005 10:16:00
>Number: 31874
>Category: lib
>Synopsis: iconv(3) return error when src string end with shift sequence.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 20 10:16:00 +0000 2005
>Originator: OBATA Akio
>Release: NetBSD 2.0.2_STABLE
>Organization:
LINS, Japan.
>Environment:
System: NetBSD miki.lins.jp 2.0.2_STABLE NetBSD 2.0.2_STABLE (MIKI) #4: Mon Aug 1 16:28:54 JST 2005 obata@miki.lins.jp:/usr/src/sys/arch/i386/compile/MIKI i386
Architecture: i386
Machine: i386
>Description:
iconv(3) return -1(error) when src string end with shift sequence.
errno is EINVAL.
It must be accepted.
>How-To-Repeat:
Here is a sample code:
======================================================================
#include <iconv.h>
#include <errno.h>
#include <stdlib.h>
int main() {
const char* src="\033$B%F%9%H\033(B";
int srcn = 12;
char* dst;
int dstn = 24;
iconv_t cd;
dst = malloc(24);
cd = iconv_open("UTF-8", "iso-2022-jp");
if(iconv(cd, &src, &srcn, &dst, &dstn) == (size_t)-1)
perror(NULL);
iconv_close(cd);
}
======================================================================
Result:
======================================================================
Invalid argument
======================================================================
>Fix:
N/A