From 5fd774821e1f34df01be7a72eb6482bba5bb0331 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 30 Jan 2015 00:26:24 +0000 Subject: [PATCH] link/mkdir: error link counter overrun --- Kernel/syscall_fs2.c | 5 +++++ Kernel/syscall_other.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Kernel/syscall_fs2.c b/Kernel/syscall_fs2.c index aacfde33..5357fa68 100644 --- a/Kernel/syscall_fs2.c +++ b/Kernel/syscall_fs2.c @@ -551,6 +551,11 @@ arg_t _link(void) if (getmode(ino) == F_DIR && esuper()) goto nogood; + if (ino->c_node.i_nlink == 0xFFFF) { + udata.u_error = EMLINK; + goto nogood; + } + /* Make sure file2 doesn't exist, and get its parent */ if ((ino2 = n_open(name2, &parent2)) != NULL) { i_deref(ino2); diff --git a/Kernel/syscall_other.c b/Kernel/syscall_other.c index f41475d0..be2e54c6 100644 --- a/Kernel/syscall_other.c +++ b/Kernel/syscall_other.c @@ -125,6 +125,11 @@ arg_t _mkdir(void) return (-1); } + if (parent->c_node.i_nlink == 0xFFFF) { + udata.u_error = EMLINK; + goto nogood2; + } + filename(name, fname); i_ref(parent); /* We need it again in a minute */ -- 2.34.1