sys_readlink: return the length of the string NOT including NULL
authorRonald G. Minnich <rminnich@google.com>
Wed, 16 Jul 2014 15:23:25 +0000 (08:23 -0700)
committerRonald G. Minnich <rminnich@google.com>
Wed, 16 Jul 2014 16:00:37 +0000 (09:00 -0700)
For consistency with things like getcwd. Note that we should not be
able to return a negative number as the retlen is strlen(...) + 1.

This makes path/filepath go testing work.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/src/syscall.c

index 4857a19..d0ad908 100644 (file)
@@ -1469,7 +1469,7 @@ intreg_t sys_readlink(struct proc *p, char *path, size_t path_l,
        if (symname){
                copy_amt = strnlen(symname, buf_l - 1) + 1;
                if (! memcpy_to_user_errno(p, u_buf, symname, copy_amt))
-                       ret = copy_amt;
+                       ret = copy_amt - 1;
        }
        if (path_d)
                kref_put(&path_d->d_kref);