Skip to content

Commit

Permalink
srm: fix semi-infinite ls range with non-zero offset
Browse files Browse the repository at this point in the history
The SRM protocol allows the client to request a directory listing with
an offset but no length.  Internally, we represent this situation as
if the client requested Integer.MAX_VALUE responses.

Later, we build a Range describing the requested directory listing; however,
this fails to take into account that adding a small positive integer to
Integer.MAX_VALUE results in a negative number, which triggers an
IllegalArguementException.

This is fixed so that if the index of last requested item is
Integer.MAX_VALUE or more then a semi-infinite range is generated instead.

Target: master
Ticket: http://rt.dcache.org/Ticket/Display.html?id=7181
Ticket: http://rt.dcache.org/Ticket/Display.html?id=8550
Patch: https://rb.dcache.org/r/7613/
Acked-by: Gerd Behrmann
Request: 2.11
Request: 2.10
Request: 2.9
Request: 2.8
Request: 2.7
Request: 2.6
  • Loading branch information
paulmillar committed Dec 17, 2014
1 parent 6fd2d8e commit 25eb7c0
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2443,8 +2443,9 @@ public void print(FsPath dir, FileAttributes dirAttr, DirectoryEntry entry)
Subject subject = ((DcacheUser) user).getSubject();
FmdListPrinter printer =
verbose ? new VerboseListPrinter() : new FmdListPrinter();
_listSource.printDirectory(subject, printer, path, null,
Range.closedOpen(offset, offset + count));
Range<Integer> range = offset < Integer.MAX_VALUE - count ?
Range.closedOpen(offset, offset + count) : Range.atLeast(offset);
_listSource.printDirectory(subject, printer, path, null, range);
return printer.getResult();
} catch (TimeoutCacheException e) {
throw new SRMInternalErrorException("Internal name space timeout", e);
Expand Down

0 comments on commit 25eb7c0

Please sign in to comment.