Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5041655

(ch) FileLock: negative param and overflow issues

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      sparc
    • OS:
      solaris_9

      Description

      The Right Thing is to apply the same checks to overlaps() as to the
      constructor.

      static void checkValidRange(long position, long size) {
      if (position < 0)
      throw new IllegalArgumentException("Negative position");
      if (size < 0)
      throw new IllegalArgumentException("Negative size");
      if (position + size < 0)
      throw new IllegalArgumentException("Negative position + size");
      }

      We could call the above in both the constructor and overlaps().
      What happens if the caller passes negative values to overlaps()?

      But this is slightly incompatible. No doubt some application is
      relying on being able to pass negative args to overlaps(). Anyways, a
      CCC is called for to settle this issue.

          public final boolean overlaps(long position, long size) {
              checkValidRange(position, size);
              return ((position + size > this.position) &&
                      (this.position + this.size > position));
          }

      ###@###.###

        Attachments

          Activity

            People

            • Assignee:
              bpb Brian Burkhalter
              Reporter:
              mmcclosksunw Michael Mccloskey (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: