Re: [protobuf] Re: validating protobuf messages

2017-12-10 Thread Marc Gravell
a zero tag is never valid in any protobuf data, although it wouldn't be
unheard of for folks to use a zero tag as a sentinel value to demark
multiple root messages. Protoc has some facilities to check the insides of
a message that might help you figure out how likely it is to be a match,
but it won't make a zero tag work.

On 10 Dec 2017 6:35 p.m., "Annu Bansal"  wrote:

> Hey Jeroen!
> Dis you get any method to check if a .pb file is generated from givem
> .proto file? Actually, I'm getting error while deserializing a .pb file,
> "The protocol message contained invalid tag(zero)." I was wondering if the
> two files are compatible.
> Thanks in advance.
>
> On Saturday, November 17, 2012 at 5:38:16 AM UTC+5:30, Jeroen Ooms wrote:
>>
>> I am using the RProtoBuf package, which interfaces to the c++ protobuf
>> library. I was wondering if there is any way of 'validating' a pb
>> message, in the sense that you can check if it actually is a valid
>> message for a given pb description. Currently, RProtoBuf is very
>> permissive and will basically accept anything. E.g the code below will
>> not throw an error, even though the file obviously is not a valid
>> tutorial.Person message:
>>
>> library(RProtoBuf)
>> read(tutorial.Person, "/etc/passwd")
>>
>> In practice, it is quite easy to introduce errors by accidentally reading
>> a message using the wrong description. It would be very helpful if there
>> was a way of preventing this kind of problems by some sort of validation.
>>
>> Is there support for this in the c++ library, or does protobuf basically
>> assume that the user/application has some other way of validating a message?
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: validating protobuf messages

2017-12-10 Thread Annu Bansal
Hey Jeroen!
Dis you get any method to check if a .pb file is generated from givem 
.proto file? Actually, I'm getting error while deserializing a .pb file, 
"The protocol message contained invalid tag(zero)." I was wondering if the 
two files are compatible. 
Thanks in advance. 

On Saturday, November 17, 2012 at 5:38:16 AM UTC+5:30, Jeroen Ooms wrote:
>
> I am using the RProtoBuf package, which interfaces to the c++ protobuf 
> library. I was wondering if there is any way of 'validating' a pb 
> message, in the sense that you can check if it actually is a valid 
> message for a given pb description. Currently, RProtoBuf is very 
> permissive and will basically accept anything. E.g the code below will 
> not throw an error, even though the file obviously is not a valid 
> tutorial.Person message:
>
> library(RProtoBuf)
> read(tutorial.Person, "/etc/passwd")
>
> In practice, it is quite easy to introduce errors by accidentally reading 
> a message using the wrong description. It would be very helpful if there 
> was a way of preventing this kind of problems by some sort of validation.
>
> Is there support for this in the c++ library, or does protobuf basically 
> assume that the user/application has some other way of validating a message?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: validating protobuf messages

2012-11-19 Thread alex
What's the definition of Validate? pb support optional fields, extensions 
, that means you can ignore unknown fields.
If some fields are necessary why not just set to required.  

On Saturday, November 17, 2012 8:08:16 AM UTC+8, Jeroen Ooms wrote:

 I am using the RProtoBuf package, which interfaces to the c++ protobuf 
 library. I was wondering if there is any way of 'validating' a pb 
 message, in the sense that you can check if it actually is a valid 
 message for a given pb description. Currently, RProtoBuf is very 
 permissive and will basically accept anything. E.g the code below will 
 not throw an error, even though the file obviously is not a valid 
 tutorial.Person message:

 library(RProtoBuf)
 read(tutorial.Person, /etc/passwd)

 In practice, it is quite easy to introduce errors by accidentally reading 
 a message using the wrong description. It would be very helpful if there 
 was a way of preventing this kind of problems by some sort of validation.

 Is there support for this in the c++ library, or does protobuf basically 
 assume that the user/application has some other way of validating a message?



-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/FH6vdkgPDg8J.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.