[zeromq-dev] Zproto framesize calculation for UTF-8 in Java

Stephen Riesenberg stephen.riesenberg at gmail.com
Fri Mar 10 07:34:23 CET 2017


Marcel,

If you need help, I can look at this as well. The only issue with a fix
will be the need to either invoke the String#getBytes(...) method twice or
refactor the codec a bit. I don't know of a way to easily determine the
number of bytes in a string without just converting to bytes in your
desired encoding (UTF-8).

If interested, I'm also doing some work that I may add to zproto at some
point for a codec that supports jzmq-api. The Message class is handling a
lot of that now (not merged to main repo yet) so the codec gets a lot
cleaner. https://github.com/sjohnr/jyre/blob/master/model/zmq_socket.gsl

On Thu, Mar 9, 2017 at 8:40 AM Kevin Sapper <kevinsapper88 at gmail.com> wrote:

> Hi Marcel,
>
> this seems to be a bug. Can you send a PR to fix this issue.
>
> Thanks!
>
> //Kevin
>
>
> On Do, Mär 9, 2017 at 2:56 , Marcel Möhring <marcel.moehring at catapullt.de>
> wrote:
>
> Hi,
>
> I’m experiencing a buffer overflow when using utf-8 with an zproto/gsl
> generated message class.
>
> The framesize for strings seems to be calculated based on the number of
> characters in a string.
> Later the bytes of the string are put into a buffer and when the string
> contains multi byte characters, the buffer overflows.
>
> Has anyone else experienced this behavior?
> Or is this behavior intended, i.e. am I using it wrong?
>
> Cheers,
> Marcel
>
>
> --
> marcel.moehring at catapullt.de
> http://www.catapullt.de/
>
> Büro: +49 202 430427-20
> Mobil: +49 173 7265151
> Fax: +49 202 430427-09
>
> catapullt GmbH & Co. KG
> In der Gelpe 79
> 42349 Wuppertal
>
> Geschäftsführer: Jürgen Weinrich
> Amtsgericht: Wuppertal, HRA: 22523
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20170310/637a7503/attachment.htm>


More information about the zeromq-dev mailing list