mojira.dev
MC-6699

Reading Bytes in Minecraft code has a possible flaw

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)

Comments 0

No comments.

David Herberth

Nathan Adams

Unconfirmed

Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w01b

Snapshot 13w02a

Retrieved