File tree Expand file tree Collapse file tree
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -391,6 +391,14 @@ static boolean decodeModuleHasTargetSystemOverrides(byte flags) {
391391 }
392392
393393 static short encodeTargetSystems (Set <InstrumenterModule .TargetSystem > targetSystems ) {
394+ final int allTargetSystemsCount = InstrumenterModule .TargetSystem .values ().length ;
395+ // Safety check to ensure we don’t overflow the index if additional TargetSystem enums are added
396+ if (allTargetSystemsCount > 16 ) {
397+ throw new IllegalStateException (
398+ "Using a short will only allow encoding 16 different target systems, but found "
399+ + allTargetSystemsCount
400+ + ". Please use a larger data type for encoding/decoding this field." );
401+ }
394402 short ret = 0 ;
395403 for (InstrumenterModule .TargetSystem ts : targetSystems ) {
396404 ret |= (short ) (1 << ts .ordinal ());
You can’t perform that action at this time.
0 commit comments