lkml.org 
[lkml]   [1999]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectreadlink() 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/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.043 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site