lkml.org 
[lkml]   [1997]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.1.20 ext2fs readlink bug+fix
On Wed, 8 Jan 1997 nsd@bbc.com wrote:

> In Linux kernel 2.1.20, readlink() on an ext2 file system returns one plus the
> length of the link target. Previous kernels and other UNIXes I've checked
> return exactly the length of the link target.
>
> Here's a patch to revert to the original behavior:
>
> --- linux/fs/ext2/symlink.c.orig Fri Jan 3 21:19:25 1997
> +++ linux/fs/ext2/symlink.c Sun Jan 5 01:18:10 1997
> @@ -124,7 +124,7 @@
> link = (char *) inode->u.ext2_i.i_data;
>
> /* XXX I hope link is always '\0'-terminated. */
> - i = strlen(link)+1;
> + i = strlen(link);
> if (i > buflen)
> i = buflen;
> if (copy_to_user(buffer, link, i))

On a totally unrelated note, I see a big EEK (or aiee, depending on your
preferences) here. /* XXX I hope link is always '\0'-terminated. */ You
can hope it all you want, but if your disk gets corrupted, it's not gonna
be true. Before doing strlen on it, you should put a null as the last
byte in the array (unless it's dynamic, in which case we might be kinda
screwed).

Greg Alexander
http://www.cia-g.com/~sietch/


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