Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libperfuse getextattr: fix attribute length being report...



details:   https://anonhg.NetBSD.org/src/rev/1b275cbd66b2
branches:  trunk
changeset: 331371:1b275cbd66b2
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Aug 09 19:06:50 2014 +0000

description:
getextattr: fix attribute length being reported to caller. If buffer
is too small, return ENORANGE.

Caught by glusterFS regression tests

diffstat:

 lib/libperfuse/ops.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 4c7f2563b583 -r 1b275cbd66b2 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Sat Aug 09 19:06:49 2014 +0000
+++ b/lib/libperfuse/ops.c      Sat Aug 09 19:06:50 2014 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.64 2014/08/09 03:17:11 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.65 2014/08/09 19:06:50 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3359,9 +3359,17 @@
         */
        foh = GET_OUTHDR(ps, pm);
        np = (char *)(void *)(foh + 1);
+       len = foh->len - sizeof(*foh);
+
+       if (attrsize != NULL)
+               *attrsize = len;
 
        if (resid != NULL) {
-               len = MAX(foh->len - sizeof(*foh), *resid);
+               if (*resid < len) {
+                       error = ERANGE;
+                       goto out;
+               }
+
                (void)memcpy(attr, np, len);
                *resid -= len;
        }



Home | Main Index | Thread Index | Old Index