Skip to content

Commit

Permalink
Raise an error when decoding a field with tag 0
Browse files Browse the repository at this point in the history
Fix the following errors reported by conformance test:

CONFORMANCE TEST BEGIN ====================================

ERROR, test=Required.ProtobufInput.IllegalZeroFieldNum_Case_0: Should have failed to parse, but didn't. request=protobuf_payload: "\001DEADBEEF" requested_output_format: PROTOBUF, response=protobuf_payload: "\001DEADBEEF"
ERROR, test=Required.ProtobufInput.IllegalZeroFieldNum_Case_1: Should have failed to parse, but didn't. request=protobuf_payload: "\002\001\001" requested_output_format: PROTOBUF, response=protobuf_payload: "\002\001\001"
ERROR, test=Required.ProtobufInput.IllegalZeroFieldNum_Case_3: Should have failed to parse, but didn't. request=protobuf_payload: "\005DEAD" requested_output_format: PROTOBUF, response=protobuf_payload: "\005DEAD"

These tests failed.  If they can't be fixed right now, you can add them to the failure list so the overall suite can succeed.  Add them to the failure list by running:
  ./update_failure_list.py  --add failing_tests.txt

  Required.ProtobufInput.IllegalZeroFieldNum_Case_0
  Required.ProtobufInput.IllegalZeroFieldNum_Case_1
  Required.ProtobufInput.IllegalZeroFieldNum_Case_3

CONFORMANCE SUITE FAILED: 189 successes, 423 skipped, 0 expected failures, 3 unexpected failures.
  • Loading branch information
ahamez committed Jun 10, 2017
1 parent 872b8bc commit 055b8ae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/protox/decode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ defmodule Protox.Decode do
defp parse_key_value(set_fields, bytes, defs, msg) do
{tag, wire_type, rest} = parse_key(bytes)

if tag == 0 do
raise "Illegal field with tag 0"
end

field = defs[tag]
{new_set_fields, new_msg, new_rest} = if field do
{name, kind, type} = field
Expand Down

0 comments on commit 055b8ae

Please sign in to comment.