Skip to content

Simple-8b codec validation bypassed for Long.MAX_VALUE / Long.MIN_VALUE — silent value truncation #4336

@ruispereira

Description

@ruispereira

Affected version: 26.4.2 (confirmed still present in 26.5.1)
Component: com.arcadedb.engine.timeseries.codec.Simple8bCodec

Summary

zigzagEncode(Long.MAX_VALUE) = -2 and zigzagEncode(Long.MIN_VALUE) = -1 (both negative, signed). The validation check encoded > MAX_ZIGZAG_VALUE ((1L<<60) - 1) is false for negative values, so validation passes; the encoder then masks with (1L<<60) - 1, silently dropping the top 4 bits.

Code

engine/com/arcadedb/engine/timeseries/codec/Simple8bCodec.java:69

final long encoded = zigzagEncode(values[i]);
if (encoded > MAX_ZIGZAG_VALUE)                         // signed >, fails for negative encoded
  throw new IllegalArgumentException(…);

Impact

Any caller passing values near ±Long.MAX_VALUE (nanosecond timestamps, large counters) ingests silently-corrupted data that returns a wrong long on decode.

Suggested fix

Validate the raw input before ZigZag, or use Long.compareUnsigned(encoded, MAX_ZIGZAG_VALUE) > 0.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions