Skip to content

Commit e0ad5eb

Browse files
committed
nfs4: make sure, that we don't try to set negative filesize
Motivation: as longs in java signed, values large than 2^63 are negative. So, passing such values to filesystem on setattr fail. Modification: Update SETATTR to indicate that values large than 2^63-1 are not supported. Result: be nice to the clients and the backed filesystems Acked-by: Marina Sahakyan Target: master
1 parent ddd29bb commit e0ad5eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/main/java/org/dcache/nfs/v4/OperationSETATTR.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 - 2018 Deutsches Elektronen-Synchroton,
2+
* Copyright (c) 2009 - 2025 Deutsches Elektronen-Synchroton,
33
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
44
*
55
* This library is free software; you can redistribute it and/or modify
@@ -20,6 +20,8 @@
2020
package org.dcache.nfs.v4;
2121

2222
import java.io.IOException;
23+
24+
import org.dcache.nfs.status.FBigException;
2325
import org.dcache.nfs.v4.xdr.utf8str_cs;
2426
import org.dcache.nfs.v4.xdr.nfs4_prot;
2527
import org.dcache.nfs.v4.xdr.bitmap4;
@@ -135,6 +137,10 @@ static void xdr2fattr(int fattr , Stat stat, Inode inode, CompoundContext contex
135137
case nfs4_prot.FATTR4_SIZE :
136138
uint64_t size = new uint64_t();
137139
size.xdrDecode(xdr);
140+
// long is signed 64 bit, so, large values will be negative
141+
if (size.value < 0) {
142+
throw new FBigException("Signed long overflow");
143+
}
138144
stat.setSize(size.value);
139145
break;
140146
case nfs4_prot.FATTR4_ACL :

0 commit comments

Comments
 (0)