Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-6699

Reading Bytes in Minecraft code has a possible flaw

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Snapshot 13w02a
    • Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w01b
    • None
    • Unconfirmed

      I used MCP to debug a problem with my client, I stumbled across this code in Packet.class:

          public static byte[] readBytesFromStream(DataInputStream par0DataInputStream) throws IOException
          {
              short var1 = par0DataInputStream.readShort();
      
              if (var1 < 0)
              {
                  throw new IOException("Key was smaller than nothing!  Weird key!");
              }
              else
              {
                  byte[] var2 = new byte[var1];
                  par0DataInputStream.read(var2);
                  return var2;
              }
          }
      

      The problem lies in `par0DataInputStream.read(var2);`, it reads up to var2-bytes but not exactly var2-bytes.

      (already fixed by Dinnerbone, submitting it for the sake of completeness)

            dinnerbone [Mojang] Nathan Adams
            dav1d David Herberth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: