diff options
author | Jeremy Allison <jra@samba.org> | 2003-10-09 21:04:48 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-10-09 21:04:48 +0000 |
commit | 90b147022effcca1087a9963d46c250638bf8c46 (patch) | |
tree | 7f53f3415ab21511fd9b80d88a63110f823187a9 /source3/smbd | |
parent | 9759adc4ffd2bc56cd09ca9c4c696502c327dce1 (diff) | |
download | samba-90b147022effcca1087a9963d46c250638bf8c46.tar.gz samba-90b147022effcca1087a9963d46c250638bf8c46.tar.bz2 samba-90b147022effcca1087a9963d46c250638bf8c46.zip |
Match W2K insanty w.r.t. writelock and writeclose. Samba4 torture tester.
Jeremy.
(This used to be commit c682fae16a2fa18f951c69ba29b1a576f4e27d6b)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/reply.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 5c9451cf37..89bb5eeb94 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2159,7 +2159,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, size_t numtowrite; SMB_OFF_T startpos; char *data; - NTSTATUS status; + NTSTATUS status = NT_STATUS_OK; files_struct *fsp = file_fsp(inbuf,smb_vwv0); int outsize = 0; START_PROFILE(SMBwriteunlock); @@ -2171,7 +2171,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, + if (numtowrite && is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { END_PROFILE(SMBwriteunlock); return ERROR_DOS(ERRDOS,ERRlock); @@ -2193,11 +2193,13 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, return(UNIXERROR(ERRHRD,ERRdiskfull)); } - status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos); - if (NT_STATUS_V(status)) { - END_PROFILE(SMBwriteunlock); - return ERROR_NT(status); + if (numtowrite) { + status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, + (SMB_BIG_UINT)startpos); + if (NT_STATUS_V(status)) { + END_PROFILE(SMBwriteunlock); + return ERROR_NT(status); + } } outsize = set_message(outbuf,1,0,True); @@ -2620,7 +2622,7 @@ int reply_writeclose(connection_struct *conn, mtime = make_unix_date3(inbuf+smb_vwv4); data = smb_buf(inbuf) + 1; - if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { + if (numtowrite && is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { END_PROFILE(SMBwriteclose); return ERROR_DOS(ERRDOS,ERRlock); } @@ -2629,7 +2631,16 @@ int reply_writeclose(connection_struct *conn, set_filetime(conn, fsp->fsp_name,mtime); - close_err = close_file(fsp,True); + /* + * More insanity. W2K only closes the file if writelen > 0. + * JRA. + */ + + if (numtowrite) { + DEBUG(3,("reply_writeclose: zero length write doesn't close file %s\n", + fsp->fsp_name )); + close_err = close_file(fsp,True); + } DEBUG(3,("writeclose fnum=%d num=%d wrote=%d (numopen=%d)\n", fsp->fnum, (int)numtowrite, (int)nwritten, |