Commons IO
  1. Commons IO
  2. IO-117

EndianUtils.readSwappedUnsignedInteger() may return a negative number

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: None
    • Labels:
      None

      Description

      Methods about reading unsigned-integer in class EndianUtils may return a negative number, due to casting int to long.
      Calculations with operator & etc. are under integer in these methods so its results are integer,
      then implicit casting the results to long keeps its positive/negative sign.

      1. IO-117.patch
        2 kB
        Henri Yandell
      2. EndianUtilsTest.java
        0.7 kB
        Hiroshi Ikeda

        Activity

        Mark Thomas made changes -
        Workflow jira [ 12399830 ] Default workflow, editable Closed status [ 12601750 ]
        Henri Yandell made changes -
        Fix Version/s 1.3.2 [ 12312510 ]
        Fix Version/s 1.4 [ 12312101 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Hide
        Henri Yandell added a comment -

        Committed to both trunk (539632) and the 1.3.x branch(539638).

        My understanding is that this is in time for 1.3.2.

        Show
        Henri Yandell added a comment - Committed to both trunk (539632) and the 1.3.x branch(539638). My understanding is that this is in time for 1.3.2.
        Henri Yandell made changes -
        Fix Version/s 1.4 [ 12312101 ]
        Henri Yandell made changes -
        Attachment IO-117.patch [ 12356570 ]
        Hide
        Henri Yandell added a comment -

        Attaching a patch containing Hiroshi's test as a unit test and a proposed pair of fixes.

        Opinions sought on my fix, I don't do a lot of bit shifting so it always feels clumsy.

        Show
        Henri Yandell added a comment - Attaching a patch containing Hiroshi's test as a unit test and a proposed pair of fixes. Opinions sought on my fix, I don't do a lot of bit shifting so it always feels clumsy.
        Hiroshi Ikeda made changes -
        Field Original Value New Value
        Attachment EndianUtilsTest.java [ 12355657 ]
        Hide
        Hiroshi Ikeda added a comment -

        Here simple test case.

        Show
        Hiroshi Ikeda added a comment - Here simple test case.
        Hide
        Henri Yandell added a comment -

        Do you have any particular examples/test cases in mind where there are problems, or is this theoretical?

        Show
        Henri Yandell added a comment - Do you have any particular examples/test cases in mind where there are problems, or is this theoretical?
        Hiroshi Ikeda created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Hiroshi Ikeda
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development