Skip to content

Commit

Permalink
upb: fix uninitialized upb_MessageValue buffer bugs (#18160)
Browse files Browse the repository at this point in the history
* upb: fix uninitialized upb_MessageValue buffer bugs

Fixes #18045

This should also cover googleapis/proto-plus-python#483 once we release it.

PiperOrigin-RevId: 671934556

* Regenerate stale files

---------

Co-authored-by: Eric Salo <salo@google.com>
  • Loading branch information
mkruskal-google and ericsalo committed Sep 7, 2024
1 parent 3454ed8 commit 9deedf0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions php/ext/google/protobuf/php-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3082,7 +3082,8 @@ static upb_MessageValue jsondec_int(jsondec* d, const upb_FieldDef* f) {

/* Parse UINT32 or UINT64 value. */
static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER: {
Expand Down Expand Up @@ -3119,7 +3120,8 @@ static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
/* Parse DOUBLE or FLOAT value. */
static upb_MessageValue jsondec_double(jsondec* d, const upb_FieldDef* f) {
upb_StringView str;
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER:
Expand Down Expand Up @@ -15767,7 +15769,8 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_MiniTable* mt = upb_MessageDef_MiniTable(m);
size_t i = *iter;
size_t n = upb_MiniTable_FieldCount(mt);
const upb_MessageValue zero = {0};
upb_MessageValue zero;
memset(&zero, 0, sizeof(zero));
UPB_UNUSED(ext_pool);

// Iterate over normal fields, returning the first one that is set.
Expand Down
9 changes: 6 additions & 3 deletions ruby/ext/google/protobuf_c/ruby-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,8 @@ static upb_MessageValue jsondec_int(jsondec* d, const upb_FieldDef* f) {

/* Parse UINT32 or UINT64 value. */
static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER: {
Expand Down Expand Up @@ -2607,7 +2608,8 @@ static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
/* Parse DOUBLE or FLOAT value. */
static upb_MessageValue jsondec_double(jsondec* d, const upb_FieldDef* f) {
upb_StringView str;
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER:
Expand Down Expand Up @@ -15255,7 +15257,8 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_MiniTable* mt = upb_MessageDef_MiniTable(m);
size_t i = *iter;
size_t n = upb_MiniTable_FieldCount(mt);
const upb_MessageValue zero = {0};
upb_MessageValue zero;
memset(&zero, 0, sizeof(zero));
UPB_UNUSED(ext_pool);

// Iterate over normal fields, returning the first one that is set.
Expand Down
6 changes: 4 additions & 2 deletions upb/json/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ static upb_MessageValue jsondec_int(jsondec* d, const upb_FieldDef* f) {

/* Parse UINT32 or UINT64 value. */
static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER: {
Expand Down Expand Up @@ -748,7 +749,8 @@ static upb_MessageValue jsondec_uint(jsondec* d, const upb_FieldDef* f) {
/* Parse DOUBLE or FLOAT value. */
static upb_MessageValue jsondec_double(jsondec* d, const upb_FieldDef* f) {
upb_StringView str;
upb_MessageValue val = {0};
upb_MessageValue val;
memset(&val, 0, sizeof(val));

switch (jsondec_peek(d)) {
case JD_NUMBER:
Expand Down
3 changes: 2 additions & 1 deletion upb/reflection/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_MiniTable* mt = upb_MessageDef_MiniTable(m);
size_t i = *iter;
size_t n = upb_MiniTable_FieldCount(mt);
const upb_MessageValue zero = {0};
upb_MessageValue zero;
memset(&zero, 0, sizeof(zero));
UPB_UNUSED(ext_pool);

// Iterate over normal fields, returning the first one that is set.
Expand Down

0 comments on commit 9deedf0

Please sign in to comment.