summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ramfs.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-02-27 15:08:34 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2021-02-27 15:08:34 +0100
commit51f4f46ae05251967a6152514d9a935e960d022b (patch)
tree5f9303a4890b12327abd9596a22e541a1c03c89f /sys/src/cmd/ramfs.c
parent692919521c15531cc0bed3006fd958b164a746ab (diff)
ramfs: fix truncfile() for non multiple of extend size (64k)
The calculation of the last block size is wrong and we can only shrink the size of the last data block, not extend it.
Diffstat (limited to 'sys/src/cmd/ramfs.c')
-rw-r--r--sys/src/cmd/ramfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/src/cmd/ramfs.c b/sys/src/cmd/ramfs.c
index 85bbe9e31..90f1225e8 100644
--- a/sys/src/cmd/ramfs.c
+++ b/sys/src/cmd/ramfs.c
@@ -249,7 +249,8 @@ truncfile(File *f, vlong l)
if(i < n){
o = l % ESIZE;
if(o != 0 && x->ent[i] != nil){
- x->ent[i]->size = o * sizeof(Ram*);
+ if(o < x->ent[i]->size)
+ x->ent[i]->size = o;
i++;
}
while(i < n){