summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
authordzwdz2024-08-18 23:06:26 +0200
committerdzwdz2024-08-18 23:06:26 +0200
commit8b4a2d50de67b746bcc472bd46c55d83eff668fc (patch)
tree21bcf9814b07bc54e7705f4e9ae93528d627e838 /src/kernel/vfs/request.c
parent446acde84c7f244792bf412996678254ee296356 (diff)
kernel: basic _sys_setxattr implementationHEADmain
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c9
1 files changed, 9 insertions, 0 deletions
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);
}