unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#22667: string->bytevector encoding error
@ 2016-02-14 22:18 Josep Portella Florit
  2016-03-03 17:55 ` Mark H Weaver
  2016-06-20 16:07 ` Andy Wingo
  0 siblings, 2 replies; 4+ messages in thread
From: Josep Portella Florit @ 2016-02-14 22:18 UTC (permalink / raw)
  To: 22667

'string->bytevector' throws 'encoding-error' when the encoding is
"UTF-16" and the length of the string is greater than 128.  The same
for the encoding "UTF-32" and a string of length greater than 64.

Tested on Guile 2.0.11 and 2.1.2 with the same result.

How to reproduce:

(use-modules (ice-9 iconv))

;; These expressions evaluate as expected:
(string->bytevector (make-string 128 #\A) "UTF-16")
;; => #vu8(254 255 0 65 0 65 ...)
(string->bytevector (make-string 64 #\A) "UTF-32")
;; => #vu8(0 0 254 255 0 0 0 65 0 0 0 65 ...)

;; These expressions throw 'encoding-error':
(string->bytevector (make-string 129 #\A) "UTF-16")
(string->bytevector (make-string 65 #\A) "UTF-32")





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22667: string->bytevector encoding error
  2016-02-14 22:18 bug#22667: string->bytevector encoding error Josep Portella Florit
@ 2016-03-03 17:55 ` Mark H Weaver
  2016-06-20 16:07 ` Andy Wingo
  1 sibling, 0 replies; 4+ messages in thread
From: Mark H Weaver @ 2016-03-03 17:55 UTC (permalink / raw)
  To: Josep Portella Florit; +Cc: 22667, Ludovic Courtès

Josep Portella Florit <jpf@primfilat.com> writes:

> 'string->bytevector' throws 'encoding-error' when the encoding is
> "UTF-16" and the length of the string is greater than 128.  The same
> for the encoding "UTF-32" and a string of length greater than 64.
>
> Tested on Guile 2.0.11 and 2.1.2 with the same result.
>
> How to reproduce:
>
> (use-modules (ice-9 iconv))
>
> ;; These expressions evaluate as expected:
> (string->bytevector (make-string 128 #\A) "UTF-16")
> ;; => #vu8(254 255 0 65 0 65 ...)
> (string->bytevector (make-string 64 #\A) "UTF-32")
> ;; => #vu8(0 0 254 255 0 0 0 65 0 0 0 65 ...)
>
> ;; These expressions throw 'encoding-error':
> (string->bytevector (make-string 129 #\A) "UTF-16")
> (string->bytevector (make-string 65 #\A) "UTF-32")

Thee bug is in 'display_string_using_iconv', introduced in commit
f4bc4e5934, which improperly assumes that a 256-byte buffer
(encoded_output) will be large enough to hold the results of converting
up to 256 bytes of UTF-8 (utf8_buf) to an arbitrary encoding using
'iconv'.  When this assumption fails, the call to 'iconv' on line 997

      done = iconv (id->output_cd, &input, &input_left,
		    &output, &output_left);

reports a failure due to the output buffer being too small, and the code
fails to handle this case.

To be continued...

     Mark





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22667: string->bytevector encoding error
  2016-02-14 22:18 bug#22667: string->bytevector encoding error Josep Portella Florit
  2016-03-03 17:55 ` Mark H Weaver
@ 2016-06-20 16:07 ` Andy Wingo
  2016-08-07 21:25   ` Andy Wingo
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Wingo @ 2016-06-20 16:07 UTC (permalink / raw)
  To: Josep Portella Florit; +Cc: 22667

On Sun 14 Feb 2016 23:18, Josep Portella Florit <jpf@primfilat.com> writes:

> 'string->bytevector' throws 'encoding-error' when the encoding is
> "UTF-16" and the length of the string is greater than 128.  The same
> for the encoding "UTF-32" and a string of length greater than 64.
>
> Tested on Guile 2.0.11 and 2.1.2 with the same result.
>
> How to reproduce:
>
> (use-modules (ice-9 iconv))
>
> ;; These expressions evaluate as expected:
> (string->bytevector (make-string 128 #\A) "UTF-16")
> ;; => #vu8(254 255 0 65 0 65 ...)
> (string->bytevector (make-string 64 #\A) "UTF-32")
> ;; => #vu8(0 0 254 255 0 0 0 65 0 0 0 65 ...)
>
> ;; These expressions throw 'encoding-error':
> (string->bytevector (make-string 129 #\A) "UTF-16")
> (string->bytevector (make-string 65 #\A) "UTF-32")

For what it's worth, this appears to be fixed in 2.1.3.  However we
should fix 2.0 as well.

Andy





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22667: string->bytevector encoding error
  2016-06-20 16:07 ` Andy Wingo
@ 2016-08-07 21:25   ` Andy Wingo
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2016-08-07 21:25 UTC (permalink / raw)
  To: Josep Portella Florit; +Cc: 22667-done

Hi,

On Mon 20 Jun 2016 18:07, Andy Wingo <wingo@pobox.com> writes:

> On Sun 14 Feb 2016 23:18, Josep Portella Florit <jpf@primfilat.com> writes:
>
>> (use-modules (ice-9 iconv))
>> ;; These expressions throw 'encoding-error':
>> (string->bytevector (make-string 129 #\A) "UTF-16")
>> (string->bytevector (make-string 65 #\A) "UTF-32")
>
> For what it's worth, this appears to be fixed in 2.1.3.  However we
> should fix 2.0 as well.

Fixed.  Thanks for the report, and thanks to Mark for diagnosing the
problem.

Andy.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-07 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-14 22:18 bug#22667: string->bytevector encoding error Josep Portella Florit
2016-03-03 17:55 ` Mark H Weaver
2016-06-20 16:07 ` Andy Wingo
2016-08-07 21:25   ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).