]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced cap fetchdata len to avoid negative
authorDerrick Brashear <shadow@dementia.org>
Fri, 25 Sep 2009 07:15:40 +0000 (03:15 -0400)
committerDerrick Brashear <shadow|account-1000005@unknown>
Sun, 27 Sep 2009 00:44:14 +0000 (17:44 -0700)
when trying to read from a short or zero length file,
it's possible for sanity checking to knock the length below
zero. set a floor at zero.

Reviewed-on: http://gerrit.openafs.org/494
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 529d487d65d8561f5d0a43a4dc71f72b86efd975)
Reviewed-on: http://gerrit.openafs.org/500

src/viced/afsfileprocs.c

index bf1adc55ba623cccd7ed995cde9ff82079e6f265..f9080527be106218e383b312871ffced7a5bb68f 100644 (file)
@@ -7087,8 +7087,9 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
        Len = 0;
     }
 
-    if (Pos + Len > tlen)
-       Len = tlen - Pos;       /* get length we should send */
+    if (Pos + Len > tlen) /* get length we should send */
+       Len = ((tlen - Pos) < 0) ? 0 : tlen - Pos;
+
     (void)FDH_SEEK(fdP, Pos, 0);
     {
        afs_int32 high, low;