kenhuuu commented on code in PR #3610:
URL: https://github.com/apache/tinkerpop/pull/3610#discussion_r3730688568


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/SimpleTypeSerializer.java:
##########
@@ -68,6 +68,39 @@ public T readValue(final Buffer buffer, final 
GraphBinaryReader context, final b
      */
     protected abstract T readValue(final Buffer buffer, final 
GraphBinaryReader context) throws IOException;
 
+    /**
+     * Reads a length or element-count prefix and validates it before it is 
used to size an allocation. A negative
+     * value, or one larger than the number of bytes actually remaining in the 
buffer, cannot be legitimate since
+     * every counted element or byte needs at least one byte on the wire, so 
it is rejected rather than allowed to
+     * drive a large allocation from a small message.
+     */
+    protected static int readSizePrefix(final Buffer buffer) throws 
IOException {
+        if (buffer.readableBytes() < Integer.BYTES)
+            throw new IOException(String.format(

Review Comment:
   We should probably throw SerializationException from serializers as that is 
already a type of IOException



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to