From e95ded2edf9d407c6b7ef71b34f9441295b41144 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Fri, 13 Oct 2023 01:35:01 +0200
Subject: [PATCH] Only allow custom length for `0x04` instruction

---
 hwb1/src/hwb1/MyApplet.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java
index 02c5513..0049ced 100644
--- a/hwb1/src/hwb1/MyApplet.java
+++ b/hwb1/src/hwb1/MyApplet.java
@@ -65,12 +65,13 @@ public class MyApplet extends Applet {
 
                     if (instruction == 0x00) {
                         response = AuthorName;
+                        length = (short)response.length;
                     } else {
                         response = storage;
-                    }
 
-                    if (length > response.length) {
-                        length = (short) response.length;
+                        if (length > response.length) {
+                            length = (short) response.length;
+                        }
                     }
 
                     apdu.setOutgoingLength(length);