summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-02-26 05:55:11 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-02-26 05:55:11 +0000
commitcb786aab9af937db151ef3dc1d44d3953a0dd2e7 (patch)
treeca771e3eface9ccbca90f3c01581ebfbbd6b6c8f
parentbda4459b901ae2325642f2e591045d64a5778476 (diff)
Better fix for i_nlink oflow from imp@openbsd.org
Move the check up with the other sanity checks and unlock the vnode properly and jump to abortit, not bad when >= LINK_MAX.
-rw-r--r--sys/ufs/ufs/ufs_vnops.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 99f3e197770..9e13ad2e2ca 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.25 1999/02/26 03:35:18 art Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.26 1999/02/26 05:55:10 millert Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -932,6 +932,11 @@ abortit:
/* fvp, tdvp, tvp now locked */
dp = VTOI(fdvp);
ip = VTOI(fvp);
+ if ((nlink_t)ip->i_ffs_nlink >= LINK_MAX) {
+ VOP_UNLOCK(fvp, 0, p);
+ error = EMLINK;
+ goto abortit;
+ }
if ((ip->i_ffs_flags & (IMMUTABLE | APPEND)) ||
(dp->i_ffs_flags & APPEND)) {
VOP_UNLOCK(fvp, 0, p);
@@ -981,10 +986,6 @@ abortit:
* completing our work, the link count
* may be wrong, but correctable.
*/
- if ((nlink_t)dp->i_ffs_nlink >= LINK_MAX) {
- error = EMLINK;
- goto bad;
- }
ip->i_effnlink++;
ip->i_ffs_nlink++;
ip->i_flag |= IN_CHANGE;