diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 95be1a897d9..a1c9b3962f5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -111,6 +111,10 @@ public class DiscoveryNode implements Writeable, 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);