add bit of sanity checking for incomming AvatarEntities data

This commit is contained in:
Andrew Meadows 2018-12-08 10:36:35 -08:00
parent 0083c77280
commit 09f3b8f485
3 changed files with 14 additions and 0 deletions

View file

@ -367,6 +367,15 @@ void Avatar::updateAvatarEntities() {
// TODO? put a maximum number of tries on this?
}
} else {
// sanity check data
QUuid id;
EntityTypes::EntityType type;
EntityTypes::extractEntityTypeAndID((unsigned char*)(data.data()), data.size(), type, id);
if (id != entityID || !EntityTypes::typeIsValid(type)) {
// skip for corrupt
++dataItr;
continue;
}
// remember this hash for the future
stateItr = _avatarEntityDataHashes.insert(entityID, AvatarEntityDataHash(newHash));
}

View file

@ -58,6 +58,10 @@ REGISTER_ENTITY_TYPE(Light)
REGISTER_ENTITY_TYPE(Zone)
REGISTER_ENTITY_TYPE(Material)
bool EntityTypes::typeIsValid(EntityType type) {
return type > EntityType::Unknown && type <= EntityType::LAST;
}
const QString& EntityTypes::getEntityTypeName(EntityType entityType) {
QMap<EntityType, QString>::iterator matchedTypeName = _typeToNameMap.find(entityType);
if (matchedTypeName != _typeToNameMap.end()) {

View file

@ -109,6 +109,7 @@ public:
NUM_TYPES
} EntityType;
static bool typeIsValid(EntityType type);
static const QString& getEntityTypeName(EntityType entityType);
static EntityTypes::EntityType getEntityTypeFromName(const QString& name);
static bool registerEntityType(EntityType entityType, const char* name, EntityTypeFactory factoryMethod);