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

Potential long overflow in MountPermissionProvider.getNumEntries

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • core, security
    • None

    Description

      stillalex, just came across MountPermissionProvider.getNumEntries, which looks as follows:

      @Override
              public long getNumEntries(String principalName, long max) {
                  long num = 0;
                  for (PermissionStoreImpl store : stores) {
                      num += store.getNumEntries(principalName, max);
                      if (num >= max) {
                          break;
                      }
                  }
                  return num;
              }
      

      If I am not mistaken this may lead to long overflow similar to the one we spotted it in PermissionEntryProviderImpl.init.

      Proposed (but untested fix) could look as follows:

      @Override
              public long getNumEntries(String principalName, long max) {
                  long num = 0;
                  for (PermissionStoreImpl store : stores) {
                      num = LongUtils.safeAdd(num, store.getNumEntries(principalName, max))
                      if (num >= max) {
                          break;
                      }
                  }
                  return num;
              }
      

      wdyt?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              angela Angela Schreiber
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: