You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "jklamer (via GitHub)" <gi...@apache.org> on 2023/05/09 17:23:03 UTC

[GitHub] [avro] jklamer commented on a diff in pull request #2210: Read long length for bytes. Only allow Int sizes

jklamer commented on code in PR #2210:
URL: https://github.com/apache/avro/pull/2210#discussion_r1188914357


##########
lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java:
##########
@@ -329,9 +329,10 @@ public void skipString() throws IOException {
 
   @Override
   public ByteBuffer readBytes(ByteBuffer old) throws IOException {
-    int length = readInt();
+    long length = readLong();

Review Comment:
   so right now both string and bytes use writeInt, because there is no situation in which they can write long for this library.
   
   We can absolutely show writeInt can be read with readLong, but I believe that will just be a re-testing of the underlying zigzag variable length encoding. By definition Ints and Longs of the same value have equal encodings. (This could be added as a test comparing outputs of `org.apache.avro.io.BinaryData#encodeInt` and `org.apache.avro.io.BinaryData#encodeLong`)
   
   This change will only fix the error returned to the user when trying to read an exceptionally long bytes array. 



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org