Menu

#70 VariableParameter::SetData size handling

3.0.0
pending
nobody
None
3
2019-03-25
2017-03-16
Anonymous
No

VariableParameter::SetData() attempts to null out the rest of m_Data when data passed in is less than 15 units long, but what it actually does it set the first 15-DataSize bytes to be 15, not the last bytes. There's also an off-by-one bug in that you'd expect to be able to put VARIABLE_PARAMETER_SIZE bytes into the buffer (i.e. 16), but SetData() freaks out if you put more than 15 bytes in, so you can't actually fill up the buffer. This seems to be a running issue with the class - operator==, for example, ignores the last byte in the data buffer when doing a comparison.

Discussion

  • Karl  Jones

    Karl Jones - 2017-03-16
    • status: open --> pending
     
  • Karl  Jones

    Karl Jones - 2017-03-16

    Thanks ill look into it

     
  • James O'Laughlin

    Yes, the memset in SetData should be the following:

    // Clear extra space
        if( DataSize < 15 )
            memset( m_Data + DataSize, 0, 15 - DataSize );
    

    As for not being able to set VARIABLE_PARAMETER_SIZE worth of data, VARIABLE_PARAMETER_SIZE is the size for the whole variable parameter. The Data portion of the class is only 15 Bytes as the Type is the first byte of the strucuture. I will try and get a the above patch in later this afternoon for the memset.

     

    Last edit: James O'Laughlin 2019-03-25

Anonymous
Anonymous

Add attachments
Cancel





Monday.com Logo