Minecraft
  1. Minecraft
  2. MC-107170

writeString method of PacketBuffer is not creating correct exception text

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.10.2, Minecraft 16w38a
    • Fix Version/s: Minecraft 16w39a
    • Security Level: Minecraft - Public (Viewable by everyone)
    • Confirmation Status:
      Unconfirmed

      Description

      The bug

      When a String whose encoded length is larger than 32767 bytes should be written to a PacketBuffer the message in the exception uses the length of the String instead of the length of the byte array. This results in exceptions like "String too big (was 16000 bytes encoded, max 32767)".

      net.minecraft.network.PacketBuffer.writeString(String) (MCP 9.30, Minecraft 1.10)
      public PacketBuffer writeString(String string)
      {
          byte[] abyte = string.getBytes(Charsets.UTF_8);
      
          if (abyte.length > 32767)
          {
              // Replaced this, uses abyte.length instead of string.length()
              //throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + 32767 + ")");
              throw new EncoderException("String too big (was " + abyte.length + " bytes encoded, max " + 32767 + ")");
          }
          else
          {
              this.writeVarIntToBuffer(abyte.length);
              this.writeBytes(abyte);
              return this;
          }
      }
      

      How to reproduce

      See MC-68458

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              [Mojang] Grum (Erik Broes)
              Reporter:
              [Helper] Marcono1234
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: