Module Name: src
Committed By: manu
Date: Sat Aug 9 19:06:50 UTC 2014
Modified Files:
src/lib/libperfuse: ops.c
Log Message:
getextattr: fix attribute length being reported to caller. If buffer
is too small, return ENORANGE.
Caught by glusterFS regression tests
To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libperfuse/ops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.64 src/lib/libperfuse/ops.c:1.65
--- src/lib/libperfuse/ops.c:1.64 Sat Aug 9 03:17:11 2014
+++ src/lib/libperfuse/ops.c Sat Aug 9 19:06:50 2014
@@ -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 @@ perfuse_node_getextattr(struct puffs_use
*/
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;
}