From 263ee3a6d280e685e60f72fccf5f9951f709c0c2 Mon Sep 17 00:00:00 2001 From: deleterium Date: Mon, 16 May 2022 14:44:03 -0300 Subject: [PATCH] Fix bug on creationBytes validation --- src/brs/at/AtController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/brs/at/AtController.java b/src/brs/at/AtController.java index b4279d5cf..6c79800c1 100644 --- a/src/brs/at/AtController.java +++ b/src/brs/at/AtController.java @@ -160,6 +160,9 @@ public static int checkCreationBytes(byte[] creation, int height, int minCodePag b.getLong(); int codeLen = getLength(codePages, b); + if (codeLen == 0 && codePages == 1 && version > 2) { + codeLen = 256; + } if (codeLen < minCodePages || codeLen > codePages * 256) { throw new AtException(AtError.INCORRECT_CODE_LENGTH.getDescription()); } @@ -167,6 +170,9 @@ public static int checkCreationBytes(byte[] creation, int height, int minCodePag b.get(code, 0, codeLen); int dataLen = getLength(dataPages, b); + if (dataLen == 0 && dataPages == 1 && b.capacity() - b.position() == 256 && version > 2) { + dataLen = 256; + } if (dataLen < 0 || dataLen > dataPages * 256) { throw new AtException(AtError.INCORRECT_DATA_LENGTH.getDescription()); }