From 8b4a2d50de67b746bcc472bd46c55d83eff668fc Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 18 Aug 2024 23:06:26 +0200 Subject: kernel: basic _sys_setxattr implementation --- src/kernel/vfs/request.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/kernel/vfs/request.c') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 9c5b327..194ee49 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -174,6 +174,12 @@ vfsback_useraccept(VfsReq *req) space -= len+1; } if (req->uin) { + if (space < req->uinlen && req->type == VFSOP_SETXATTR) { + /* don't truncate xattr values */ + // TODO test + vfsreq_finish_short(req, -ERANGE); + return; + } if (req->kin) { /* save the address of the "second buffer" in id2, * which should be free */ @@ -181,6 +187,9 @@ vfsback_useraccept(VfsReq *req) res.id2 = buf; } + /* intentionally overriding the prior len */ + assert(len == 0 || req->type == VFSOP_SETXATTR); + len = min(req->uinlen, space); len = pcpy_bi(handler, buf, req->caller, req->uin, len); } -- cgit v1.2.3