add explicit check for Role enum ordinal when reading from StreamInput

This commit is contained in:
javanna 2016-03-25 22:58:37 +01:00 committed by Luca Cavanna
parent a685148268
commit e6c6632e6f
1 changed files with 4 additions and 0 deletions

View File

@ -111,6 +111,10 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
int rolesSize = in.readVInt();
this.roles = new HashSet<>(rolesSize);
for (int i = 0; i < rolesSize; i++) {
int ordinal = in.readVInt();
if (ordinal < 0 || ordinal >= Role.values().length) {
throw new IOException("Unknown Role ordinal [" + ordinal + "]");
}
roles.add(Role.values()[in.readVInt()]);
}
this.version = Version.readVersion(in);