patch-2.1.22 linux/fs/ext2/symlink.c

Next file: linux/fs/fat/misc.c
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.21/linux/fs/ext2/symlink.c linux/fs/ext2/symlink.c
@@ -124,11 +124,11 @@
 		link = (char *) inode->u.ext2_i.i_data;
 	
 	/* XXX I hope link is always '\0'-terminated. */ 	
-	i = strlen(link)+1; 
-	if (i > buflen) 
-		i = buflen; 
-	if (copy_to_user(buffer, link, i))
-		i = -EFAULT; 	
+	i = strlen(link);
+	if (i >= buflen)
+		i = buflen-1;
+	if (copy_to_user(buffer, link, i+1))
+		i = -EFAULT;
  	if (DO_UPDATE_ATIME(inode)) {
 		inode->i_atime = CURRENT_TIME;
 		inode->i_dirt = 1;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov