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

NativeImage bounds checks are incorrect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.14.4, 1.15 Pre-release 6, 1.16.1, 1.16.2, 21w06a
    • Fix Version/s: 21w18a
    • Labels:
      None
    • Confirmation Status:
      Confirmed
    • Category:
      Crash
    • Mojang Priority:
      Very Important

      Description

      Bounds checks in NativeImage are incorrect, and it uses UNSAFE to directly access memory, so misusing it can cause the JRE to completely crash instead of throwing an exception. As far as I am aware, this bug is not currently being triggered by any vanilla code that calls NativeImage.

      NativeImage should check that x and y are both >= 0.
      The checks for x <= width should be x < width
      and the checks for y <= height should be y < height.

      Affected methods:

      • NativeImage.getPixelRGBA(int, int)
      • NativeImage.setPixelRGBA(int, int, int)
      • NativeImage.getLuminanceOrAlpha(int, int)

      Note: These methods do not check for negative x or y values either.

        Attachments

          Activity

            People

            Assignee:
            xilefian [Mojang] Felix Jones
            Reporter:
            mezz mezz
            Votes:
            6 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              CHK: