patch-1.3.68 linux/fs/ncpfs/dir.c

Next file: linux/fs/ncpfs/file.c
Previous file: linux/fs/ncpfs/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.67/linux/fs/ncpfs/dir.c linux/fs/ncpfs/dir.c
@@ -96,7 +96,7 @@
 	NULL,			/* write - bad */
 	ncp_readdir,		/* readdir */
 	NULL,			/* select - default */
-	ncp_ioctl,		/* ioctl - default */
+	ncp_ioctl,		/* ioctl */
 	NULL,			/* mmap */
 	NULL,			/* no special open code */
 	NULL,			/* no special release code */
@@ -159,6 +159,11 @@
 		return -EBADF;
 	}
 
+	if (!ncp_conn_valid(NCP_SERVER(inode)))
+	{
+		return -EIO;
+	}
+
 	if (c_entry == NULL) 
 	{
 		i = sizeof (struct ncp_dirent) * NCP_READDIR_CACHE_SIZE;
@@ -640,6 +645,11 @@
 		iput(dir);
 		return -ENOENT;
 	}
+	if (!ncp_conn_valid(NCP_SERVER(dir)))
+	{
+		iput(dir);
+		return -EIO;
+	}
 
         DDPRINTK("ncp_lookup: %s, len %d\n", __name, len);
 
@@ -772,6 +782,11 @@
 		iput(dir);
 		return -ENOENT;
 	}
+	if (!ncp_conn_valid(NCP_SERVER(dir)))
+	{
+		iput(dir);
+		return -EIO;
+	}
 
 	strncpy(_name, name, len);
 	_name[len] = '\0';
@@ -779,7 +794,8 @@
 
 	if (ncp_open_create_file_or_subdir(NCP_SERVER(dir),
 					   NCP_ISTRUCT(dir), _name,
-					   OC_MODE_CREATE|OC_MODE_OPEN,
+					   OC_MODE_CREATE|OC_MODE_OPEN|
+					   OC_MODE_REPLACE,
 					   0, AR_READ|AR_WRITE,
 					   &finfo) != 0)
 	{
@@ -828,6 +844,11 @@
 		iput(dir);
 		return -ENOENT;
 	}
+	if (!ncp_conn_valid(NCP_SERVER(dir)))
+	{
+		iput(dir);
+		return -EIO;
+	}
 
 	if (ncp_open_create_file_or_subdir(NCP_SERVER(dir),
 					   NCP_ISTRUCT(dir), _name,
@@ -858,8 +879,14 @@
 		iput(dir);
 		return -ENOENT;
 	}
+	if (!ncp_conn_valid(NCP_SERVER(dir)))
+	{
+		iput(dir);
+		return -EIO;
+	}
         if (ncp_find_inode(dir, name) != NULL)
 	{
+		iput(dir);
                 error = -EBUSY;
         }
 	else
@@ -877,7 +904,7 @@
 		}
 		else
 		{
-			error = -EINVAL;
+			error = -EACCES;
 		}
         }
 	iput(dir);
@@ -896,8 +923,14 @@
 		iput(dir);
 		return -ENOENT;
 	}
+	if (!ncp_conn_valid(NCP_SERVER(dir)))
+	{
+		iput(dir);
+		return -EIO;
+	}
         if (ncp_find_inode(dir, name) != NULL)
 	{
+		iput(dir);
                 error = -EBUSY;
         }
 	else
@@ -914,7 +947,7 @@
 		}
 		else
 		{
-			error = -EINVAL;
+			error = -EACCES;
 		}
         }
 	iput(dir);
@@ -934,6 +967,12 @@
 		printk("ncp_rename: old inode is NULL or not a directory\n");
                 res = -ENOENT;
                 goto finished;
+	}
+
+	if (!ncp_conn_valid(NCP_SERVER(old_dir)))
+	{
+		res = -EIO;
+		goto finished;
 	}
 
 	if (!new_dir || !S_ISDIR(new_dir->i_mode))

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this