WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Code generated for default value checks for optional string elements (bytes) is incorrect #47

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Define a message with like:
  message CipherKeys {
    required bytes localKey = 1;
    required uint32 localKeyChkSum = 2;
    optional bytes groupKey = 3;
    optional uint32 groupKeyChkSum = 4;
  }

2. Look at the code generated for CipherKeys_write().  The code should be 
checking for empty string.  Code generate looks like:

/* Write the optional attribute only if it is different than the default value. 
*/
if(_CipherKeys->_groupKey_len != 1
 || _CipherKeys->_groupKey[0] != '0') {
    offset = write_raw_varint32((3<<3)+2, _buffer, offset);
    offset = write_raw_varint32(_CipherKeys->_groupKey_len, _buffer, offset);
    offset = write_raw_bytes(_CipherKeys->_groupKey, _CipherKeys->_groupKey_len, _buffer, offset);
  }
The check for length should be _CipherKeys->_groupKey_len != 0 and the check 
for a null string should be _CipherKeys->_groupKey[0] != '\0'

What version of the product are you using? On what operating system?
1.04M, host Windows XP, target IAR 5.51 MSP430


Original issue reported on code.google.com by [email protected] on 20 Aug 2013 at 1:35

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions