Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOF inside bytes field error occurs when exceeding specific length of bytes #11112

Closed
slotherhouse opened this issue Dec 1, 2022 · 3 comments
Assignees
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. php proto3

Comments

@slotherhouse
Copy link

What version of protobuf and what language are you using?
Version v3.21.9 of the the google/protobuf composer package.
Generated with libprotoc 3.17.0

Language: PHP

What operating system (Linux, Windows, ...) and version?
Debian linux ( 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 GNU/Linux )

What runtime / compiler are you using (e.g., python version or gcc version)
Error has been confirmed with php7.3 / php7.4 / php8.1

What did you do?
The error can be reproduced with the following .proto and php files, in a repository with protobuf installed through composer.

data.proto

syntax = "proto3";

message Message {
    SubMessage result = 1;
}

message SubMessage {
    oneof dataNullable {
        bytes data = 1;
    }
}

main.php

<?php

require_once './vendor/autoload.php';
require_once './GPBMetadata/Data.php';
require_once './Message.php';
require_once './SubMessage.php';

$subMsg = new \SubMessage();
$subMsg->setData(str_repeat('0', 33554423));
$msg = new \Message();
$msg->setResult($subMsg);

$recv = new \Message();
$recv->mergeFromString($msg->serializeToString());

Php protobuf classes generated with: protoc --php_out=./ ./data.proto

What did you expect to see
Nothing, the script should execute without error.

What did you see instead?
(Using php7.3)
PHP Fatal error: Uncaught Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Unexpected EOF inside bytes field. in /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:442
Stack trace:
#0 /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(515): Google\Protobuf\Internal\Message::parseFieldFromStreamNoTag(Object(Google\Protobuf\Internal\CodedInputStream), Object(Google\Protobuf\Internal\FieldDescriptor), NULL)
#1 /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(811): Google\Protobuf\Internal\Message->parseFieldFromStream(10, Object(Google\Protobuf\Internal\CodedInputStream), Object(Google\Protobuf\Internal\FieldDescriptor))
#2 /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBWire.php(289): Google\Protobuf\Internal\Message->parseFromStream(Object(Google\Protobuf\Internal\CodedInputStream))
#3 /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(435): Google\Protobuf\Internal\ in /home/x/php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 442

Anything else we should know about your project / environment
The error occurs on a str_repeat of exactly 33554423 or more times 0, when adjusting to 33554422 no error occurs.
The total strlen of the outer $msg when serialized to string is 33554433 ( Binary value of 10000000000000000000000001 )

@slotherhouse slotherhouse added the untriaged auto added to all issues by default when created. label Dec 1, 2022
@esorot esorot added php proto3 and removed untriaged auto added to all issues by default when created. labels Dec 1, 2022
@WarriorXK
Copy link

Is there an update on this item? I seem to have the same issue.

Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Dec 27, 2023
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. php proto3
Projects
None yet
Development

No branches or pull requests

4 participants