patch-src_libiconv_c 991 B

12345678910111213141516171819202122232425
  1. $OpenBSD: patch-src_libiconv_c,v 1.1 2014/10/02 21:12:48 naddy Exp $
  2. In the "while (cursor > input_buffer || input_char != EOF)" loop,
  3. the "cursor" pointer sometimes refers to "input_buffer" and sometimes
  4. to "output_buffer". It must refer to "input_buffer" at the start of
  5. the loop, but the present code forgets to ensure this.
  6. Examples that trigger the problem:
  7. $ perl -e 'print "\xc3\xa4"x1025' | recode utf8..latin1 | wc -c
  8. $ perl -e 'print "\xc3\xa4"x2000' | recode utf8..latin1 | wc -c
  9. --- src/libiconv.c.orig Sat Jul 1 19:13:25 2000
  10. +++ src/libiconv.c Sat Sep 27 23:47:54 2014
  11. @@ -195,9 +195,9 @@ wrapped_transform (iconv_t conversion, iconv_t convers
  12. memcpy() doesn't do here, because the regions might overlap.
  13. memmove() isn't worth it, because we rarely have to move more
  14. than 12 bytes. */
  15. + cursor = input_buffer;
  16. if (input > input_buffer && input_left > 0)
  17. {
  18. - cursor = input_buffer;
  19. do
  20. *cursor++ = *input++;
  21. while (--input_left > 0);