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

Reading Bytes in Minecraft code has a possible flaw

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w01b
    • Fix Version/s: Snapshot 13w02a
    • Labels:
      None
    • Confirmation Status:
      Unconfirmed

      Description

      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)

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: