Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-2388

Possibility of overflow in file length calculation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0.10, 1.1.5
    • lucene
    • None

    Description

      In OakDirectory the length of a file is calculated in following way

      OakDirectory
              public OakIndexFile(String name, NodeBuilder file) {
                  ...
                  this.blobSize = determineBlobSize(file);
                  this.blob = new byte[blobSize];
      
                  PropertyState property = file.getProperty(JCR_DATA);
                  if (property != null && property.getType() == BINARIES) {
                      this.data = newArrayList(property.getValue(BINARIES));
                  } else {
                      this.data = newArrayList();
                  }
      
                  this.length = data.size() * blobSize;
                  if (!data.isEmpty()) {
                      Blob last = data.get(data.size() - 1);
                      this.length -= blobSize - last.length();
                  }
      

      In above calculation its possible to have an overflow in

      this.length = data.size() * blobSize;

      As multiplication of two integers result in an integer [1]

      [1] http://stackoverflow.com/questions/12861893/casting-result-of-multiplication-two-positive-integers-to-long-is-negative-value

      Attachments

        Issue Links

          Activity

            People

              chetanm Chetan Mehrotra
              chetanm Chetan Mehrotra
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: