This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bug in ISO-2022-CN-EXT converter



Hi,

There is a bug in the ISO-2022-CN-EXT converter: It reacts to invalid input
with a core dump.

# printf '\x0e\x00' | iconv -f ISO-2022-CN-EXT -t UTF-8 > /dev/null
iconv: ../iconv/loop.c:267: from_iso2022cn_ext_loop: Zusicherung »(ann & SO_ann) == ISO_IR_165_ann« nicht erfüllt.
Abgebrochen (core dumped)

Here is a fix. With it, it simply prints

# printf '\x0e\x00' | iconv -f ISO-2022-CN-EXT -t UTF-8 > /dev/null
iconv: ungültige Eingabe-Sequenz an der Stelle 1



2001-05-14  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/iso-2022-cn-ext.c (BODY for FROM_LOOP): If SO is seen
	without previous announcement, reject it regularly, don't abort.

*** glibc-20010430/iconvdata/iso-2022-cn-ext.c.bak	Mon Dec  4 19:53:43 2000
--- glibc-20010430/iconvdata/iso-2022-cn-ext.c	Tue May 15 01:04:29 2001
***************
*** 260,280 ****
  	   XXX For now I'll default to use GB2312.  If this is not the	      \
  	   best behavior (e.g., we should flag an error) let me know.  */     \
  	++inptr;							      \
! 	switch (ann & SO_ann)						      \
  	  {								      \
! 	  case GB2312_ann:						      \
! 	    set = GB2312_set;						      \
! 	    break;							      \
! 	  case GB12345_ann:						      \
! 	    set = GB12345_set;						      \
! 	    break;							      \
! 	  case CNS11643_1_ann:						      \
! 	    set = CNS11643_1_set;					      \
! 	    break;							      \
! 	  default:							      \
! 	    assert ((ann & SO_ann) == ISO_IR_165_ann);			      \
! 	    set = ISO_IR_165_set;					      \
! 	    break;							      \
  	  }								      \
  	continue;							      \
        }									      \
--- 257,289 ----
  	   XXX For now I'll default to use GB2312.  If this is not the	      \
  	   best behavior (e.g., we should flag an error) let me know.  */     \
  	++inptr;							      \
! 	if ((ann & SO_ann) != 0)					      \
! 	  switch (ann & SO_ann)						      \
! 	    {								      \
! 	    case GB2312_ann:						      \
! 	      set = GB2312_set;						      \
! 	      break;							      \
! 	    case GB12345_ann:						      \
! 	      set = GB12345_set;					      \
! 	      break;							      \
! 	    case CNS11643_1_ann:					      \
! 	      set = CNS11643_1_set;					      \
! 	      break;							      \
! 	    case ISO_IR_165_ann:					      \
! 	      set = ISO_IR_165_set;					      \
! 	      break;							      \
! 	    default:							      \
! 	      abort ();							      \
! 	    }								      \
! 	else								      \
  	  {								      \
! 	    if (! ignore_errors_p ())					      \
! 	      {								      \
! 		result = __GCONV_ILLEGAL_INPUT;				      \
! 		break;							      \
! 	      }								      \
! 	    ++inptr;							      \
! 	    ++*irreversible;						      \
  	  }								      \
  	continue;							      \
        }									      \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]