From e6c6632e6f41e15564096dcaeb80635d5549a611 Mon Sep 17 00:00:00 2001 From: javanna Date: Fri, 25 Mar 2016 22:58:37 +0100 Subject: [PATCH] add explicit check for Role enum ordinal when reading from StreamInput --- .../java/org/elasticsearch/cluster/node/DiscoveryNode.java | 4 ++++ 1 file changed, 4 insertions(+) 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);