aakash-sahai / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Example does not check buffer length #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

My message struct:

message msg {
    required string name = 1 [(nanopb).max_size = 16];
    required int32 cmd = 2;
    required int32 start = 3;
    required int32 len = 4;
    optional bytes data = 5 [(nanopb).max_size = 512];
}

When msg.data.size = 512 - pb_decode do not decode message. for example 
msg.data.size = 256 work nice!

What version of the product are you using? On what operating system?

Last repositary wersion

Original issue reported on code.google.com by c4simba on 17 Sep 2012 at 1:45

GoogleCodeExporter commented 9 years ago
Ok, I can reproduce the problem. Seems to occur with data size > 501 bytes.

Original comment by Petteri.Aimonen on 17 Sep 2012 at 2:26

GoogleCodeExporter commented 9 years ago
Ah, actually; the error was in my test program.

I had
    uint8_t buffer[512];
    size_t count = fread(buffer, 1, sizeof(buffer), stdin);
and the message was longer than 512 bytes.

Does your test program perhaps have the same bug?

Original comment by Petteri.Aimonen on 17 Sep 2012 at 2:29

GoogleCodeExporter commented 9 years ago
Yes! Thanks for your time.

Original comment by c4simba on 18 Sep 2012 at 5:28

GoogleCodeExporter commented 9 years ago
Nice that you got it working :)

I'll add a check to test_decode1.c, so that if anyone else uses it as a 
starting point they won't have the same problem.

Original comment by Petteri.Aimonen on 18 Sep 2012 at 1:52

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 3f563792adb8.

Original comment by Petteri.Aimonen on 18 Sep 2012 at 1:53

GoogleCodeExporter commented 9 years ago
Fixed in nanopb-0.1.7

Original comment by Petteri.Aimonen on 12 Nov 2012 at 7:33