[protobuf] Restricting int32 field to numeric range

544 views
Skip to first unread message

Jocelyn Wei

unread,
Jul 27, 2018, 3:17:01 PM7/27/18
to prot...@googlegroups.com
I'm building a fuzzer tool that uses protobuf to define input structures, and fuzz accordingly. I would like to restrict certain fields to a range of values (for example, -2^5 to 2^5, or -2^12 to 2^12, and so on).

I've looked at this thread (https://groups.google.com/forum/#!topic/protobuf/KhZtMr78U7Y) but am not sure of the answer yet, and the thread seems dead. Is there any way to restrict values in Protobuf directly, or do I have to handle this externally, in the tool's cpp code / somewhere else?

Adam Cozzette

unread,
Jul 27, 2018, 3:45:12 PM7/27/18
to jsw...@ucsd.edu, Protocol Buffers
There is no built-in support for this kind of thing, so you would have to implement it on your own. I think one of the main reasons we haven't included this sort of feature is that it gets difficult to reason about how constraints or validation could change over time. The only kind of validation we support is required fields in proto2, and the general consensus in retrospect is that they were a mistake. Lots of fields that originally made sense as "required" eventually became obsolete and deprecated, but we still have to populate them with dummy data just to satisfy the required validation. Constraints seem like they could be worthwhile for certain use cases, but we don't plan to include them within protobuf itself.

On Fri, Jul 27, 2018 at 12:16 PM Jocelyn Wei <jsw...@ucsd.edu> wrote:
I'm building a fuzzer tool that uses protobuf to define input structures, and fuzz accordingly. I would like to restrict certain fields to a range of values (for example, -2^5 to 2^5, or -2^12 to 2^12, and so on).

I've looked at this thread (https://groups.google.com/forum/#!topic/protobuf/KhZtMr78U7Y) but am not sure of the answer yet, and the thread seems dead. Is there any way to restrict values in Protobuf directly, or do I have to handle this externally, in the tool's cpp code / somewhere else?

--
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+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages