mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-5569: add negative size checks in Go generator when reading maps, sets and lists
Client: go
This commit is contained in:
parent
edcad983d9
commit
8987820e84
@ -3369,6 +3369,9 @@ void t_go_generator::generate_deserialize_container(ostream& out,
|
||||
// Declare variables, read header
|
||||
if (ttype->is_map()) {
|
||||
out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << endl;
|
||||
out << indent() << "if size < 0 {" << endl;
|
||||
out << indent() << " return errors.New(\"map size is negative\")" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
out << indent() << "if err != nil {" << endl;
|
||||
out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
@ -3376,6 +3379,9 @@ void t_go_generator::generate_deserialize_container(ostream& out,
|
||||
out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << endl;
|
||||
} else if (ttype->is_set()) {
|
||||
out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << endl;
|
||||
out << indent() << "if size < 0 {" << endl;
|
||||
out << indent() << " return errors.New(\"set size is negative\")" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
out << indent() << "if err != nil {" << endl;
|
||||
out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
@ -3383,6 +3389,9 @@ void t_go_generator::generate_deserialize_container(ostream& out,
|
||||
out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << endl;
|
||||
} else if (ttype->is_list()) {
|
||||
out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << endl;
|
||||
out << indent() << "if size < 0 {" << endl;
|
||||
out << indent() << " return errors.New(\"list size is negative\")" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
out << indent() << "if err != nil {" << endl;
|
||||
out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << endl;
|
||||
out << indent() << "}" << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user