test for stream size

This commit is contained in:
Eric House 2024-03-04 10:21:08 -08:00
parent abc0a8c78a
commit 2b58cc702a

View file

@ -559,7 +559,7 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic,
XP_LOGFF( "bad message: too short" ); XP_LOGFF( "bad message: too short" );
} else if ( proto == PROTO_1 || proto == PROTO_3 ) { } else if ( proto == PROTO_1 || proto == PROTO_3 ) {
MQTTDevID senderID; MQTTDevID senderID;
stream_getBytes( stream, &senderID, sizeof(senderID) ); if ( stream_gotBytes( stream, &senderID, sizeof(senderID) ) ) {
senderID = be64toh( senderID ); senderID = be64toh( senderID );
#ifdef DEBUG #ifdef DEBUG
XP_UCHAR tmp[32]; XP_UCHAR tmp[32];
@ -601,6 +601,9 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic,
XP_LOGFF( "unknown command %d; dropping message", cmd ); XP_LOGFF( "unknown command %d; dropping message", cmd );
// XP_ASSERT(0); // XP_ASSERT(0);
} }
} else {
XP_LOGFF( "no senderID found; bailing" );
}
} else { } else {
XP_LOGFF( "bad proto %d; dropping packet", proto ); XP_LOGFF( "bad proto %d; dropping packet", proto );
} }