yaffs: Handle attribute size query correctly. pre-block-summary
authorCharles Manning <cdhmanning@gmail.com>
Tue, 12 Apr 2011 22:20:06 +0000 (10:20 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 12 Apr 2011 22:20:06 +0000 (10:20 +1200)
If getxattr() is passed a buffer size of zero then this is a size query.
Return the size of the attribute without copying it out.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_nameval.c

index e75411be9fb7dfef4e3f6866347a35cc88140881..487b03e19fd9a6f0fb06800f7dde867602ccdc16 100644 (file)
@@ -146,6 +146,12 @@ int nval_get(const char *xb, int xb_size, const YCHAR * name, char *buf,
                pos++;
                size--;
 
+               /* If bsize is zero then this is a size query.
+                * Return the size, but don't copy.
+                */
+               if (!bsize)
+                       return size;
+
                if (size <= bsize) {
                        memcpy(buf, xb + pos, size);
                        return size;