Skip to content

Commit

Permalink
Merge pull request #401 from SailCast/master
Browse files Browse the repository at this point in the history
Fix for invalid length GetVarStr
  • Loading branch information
ttlappalainen authored May 23, 2024
2 parents c0e04c3 + db97467 commit 697e3de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/N2kMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ bool tN2kMsg::GetStr(size_t StrBufSize, char *StrBuf, size_t Length, unsigned ch

//*****************************************************************************
bool tN2kMsg::GetVarStr(size_t &StrBufSize, char *StrBuf, int &Index) const {
size_t Len=GetByte(Index)-2;
size_t Len=GetByte(Index);
uint8_t Type=GetByte(Index);
if ( Len<2) { StrBufSize=0; return false; } // invalid length
Len-=2;
if ( Type!=0x01 ) { StrBufSize=0; return false; }
if ( StrBuf!=0 ) {
GetStr(StrBufSize,StrBuf,Len,0xff,Index);
Expand Down

0 comments on commit 697e3de

Please sign in to comment.