Skip to content

Commit

Permalink
nfs4: fix write record handling
Browse files Browse the repository at this point in the history
Ticket: #5280
(cherry picked from commit 95f0424)
  • Loading branch information
catenacyber authored and victorjulien committed Dec 15, 2022
1 parent 44a2e59 commit 9385976
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rust/src/nfs/nfs4.rs
Expand Up @@ -51,6 +51,11 @@ impl NFSState {
fill_bytes = 4 - pad;
}

// linux defines a max of 1mb. Allow several multiples.
if w.write_len == 0 || w.write_len > 16777216 {
return;
}

let file_handle = fh.to_vec();
let file_name = if let Some(name) = self.namemap.get(fh) {
SCLogDebug!("WRITE name {:?}", name);
Expand Down Expand Up @@ -96,8 +101,8 @@ impl NFSState {
}
}
self.ts_chunk_xid = r.hdr.xid;
let file_data_len = w.data.len() as u32 - fill_bytes as u32;
self.ts_chunk_left = w.write_len as u32 - file_data_len as u32;
debug_validate_bug_on!(w.data.len() as u32 > w.write_len);
self.ts_chunk_left = w.write_len as u32 - w.data.len() as u32;
}

fn close_v4<'b>(&mut self, r: &RpcPacket<'b>, fh: &'b[u8])
Expand Down

0 comments on commit 9385976

Please sign in to comment.