Skip to content

Fix MessageUnpacker#unpackString in case that string length is more than...#215

Merged
xerial merged 1 commit intov07-developfrom
issue_209
Apr 4, 2015
Merged

Fix MessageUnpacker#unpackString in case that string length is more than...#215
xerial merged 1 commit intov07-developfrom
issue_209

Conversation

@komamitsu
Copy link
Member

I modified MessageUnpacker#unpackString to fix #209.

@xerial Can you review this change?

@xerial
Copy link
Member

xerial commented Apr 4, 2015

I found another bug; This part should use ensure(strLen-cursor):

    while(cursor < strLen) {
                     if (!ensure(strLen))
                         throw new EOFException();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no guarantee that the read length from the input always matches Math.min(buffer.size() - position, strLen-cursor) when OVERFLOW (output buffer has insufficient space) happens. When OVERFLOW occurs, the input data might be partially read. That is why I compute readLen as bb.limit() - bb.remaining().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I was wrong. readLen can be retrieved by bb.position() since we created a new ByteBuffer at

ByteBuffer bb = buffer.toByteBuffer(position, readLen);

whose initial position is 0.

@xerial
Copy link
Member

xerial commented Apr 4, 2015

Now I got it. I don't need to set readLen in while(bb.hasRamaining()) loop. Thanks

xerial added a commit that referenced this pull request Apr 4, 2015
Fix MessageUnpacker#unpackString in case that string length is more than...
@xerial xerial merged commit 7cd8f41 into v07-develop Apr 4, 2015
@xerial xerial deleted the issue_209 branch May 28, 2015 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants