Messages in this thread Patch in this message | | | Date | Sat, 20 Mar 1999 16:52:30 +0100 (CET) | From | Koblinger Egmont <> | Subject | readlink() returns zero-terminated string |
| |
Hi!
I've just found that the readlink() call returns a zero-terminated string when called on an entry under /proc which points to a filename. The return value also contains this terminating zero. For example readlink("/proc/self/root", buf, many) puts "/\0" to buf and returns 2, though it should put only "/" to buf and return 1.
I think this simple patch fixes the problem (at least it works ok for me)
--- linux-2.2.3.orig/fs/proc/link.c Sun Sep 20 00:11:37 1998 +++ linux-2.2.3/fs/proc/link.c Sat Mar 20 15:59:46 1999 @@ -158,7 +158,7 @@ path = tmp; } else { path = d_path(dentry, tmp, PAGE_SIZE); - len = tmp + PAGE_SIZE - path; + len = tmp + PAGE_SIZE - 1 - path; } if (len < buflen)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |