1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r23727: Explicitly pass down FLAGS2 to srvstr_get_path.

Next step is to remove the bug that in the trans2 code we use the inbuf
as the base pointer to decide whether we need ucs2 alignment where we
need to use the beginning of the params buffer

Jeremy, last one for today to reviw :-)
(This used to be commit 18078b9faa)
This commit is contained in:
Volker Lendecke 2007-07-05 16:36:15 +00:00 committed by Gerald (Jerry) Carter
parent fcda5b5896
commit 8724dfe551
3 changed files with 111 additions and 44 deletions

View File

@ -562,7 +562,9 @@ int reply_ntcreate_and_X(connection_struct *conn,
if(!dir_fsp->is_directory) {
srvstr_get_path(inbuf, fname, smb_buf(inbuf), sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname,
smb_buf(inbuf), sizeof(fname), 0,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntcreateX);
return ERROR_NT(status);
@ -604,14 +606,18 @@ int reply_ntcreate_and_X(connection_struct *conn,
dir_name_len++;
}
srvstr_get_path(inbuf, rel_fname, smb_buf(inbuf), sizeof(rel_fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), rel_fname,
smb_buf(inbuf), sizeof(rel_fname), 0,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntcreateX);
return ERROR_NT(status);
}
pstrcat(fname, rel_fname);
} else {
srvstr_get_path(inbuf, fname, smb_buf(inbuf), sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname,
smb_buf(inbuf), sizeof(fname), 0,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntcreateX);
return ERROR_NT(status);
@ -1011,7 +1017,9 @@ static int do_nt_transact_create_pipe( connection_struct *conn, char *inbuf, cha
flags = IVAL(params,0);
srvstr_get_path(inbuf, fname, params+53, sizeof(fname), parameter_count-53, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, params+53,
sizeof(fname), parameter_count-53, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -1288,7 +1296,10 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
}
if(!dir_fsp->is_directory) {
srvstr_get_path(inbuf, fname, params+53, sizeof(fname), parameter_count-53, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname,
params+53, sizeof(fname),
parameter_count-53, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -1322,14 +1333,19 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
{
pstring tmpname;
srvstr_get_path(inbuf, tmpname, params+53, sizeof(tmpname), parameter_count-53, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), tmpname,
params+53, sizeof(tmpname),
parameter_count-53, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
pstrcat(fname, tmpname);
}
} else {
srvstr_get_path(inbuf, fname, params+53, sizeof(fname), parameter_count-53, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, params+53,
sizeof(fname), parameter_count-53,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -1842,7 +1858,9 @@ int reply_ntrename(connection_struct *conn,
init_smb_request(&req, (uint8 *)inbuf);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path_wcard(inbuf, oldname, p, sizeof(oldname), 0, STR_TERMINATE, &status, &src_has_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), oldname, p,
sizeof(oldname), 0, STR_TERMINATE, &status,
&src_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntrename);
return ERROR_NT(status);
@ -1860,7 +1878,9 @@ int reply_ntrename(connection_struct *conn,
}
p++;
p += srvstr_get_path_wcard(inbuf, newname, p, sizeof(newname), 0, STR_TERMINATE, &status, &dest_has_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), newname, p,
sizeof(newname), 0, STR_TERMINATE, &status,
&dest_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntrename);
return ERROR_NT(status);
@ -2054,8 +2074,9 @@ static int call_nt_transact_rename(connection_struct *conn, char *inbuf, char *o
fsp = file_fsp(params, 0);
replace_if_exists = (SVAL(params,2) & RENAME_REPLACE_IF_EXISTS) ? True : False;
CHECK_FSP(fsp, conn);
srvstr_get_path_wcard(inbuf, new_name, params+4, sizeof(new_name), parameter_count - 4,
STR_TERMINATE, &status, &dest_has_wcard);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), new_name, params+4,
sizeof(new_name), parameter_count - 4,
STR_TERMINATE, &status, &dest_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}

View File

@ -209,8 +209,9 @@ NTSTATUS check_path_syntax_posix(char *path)
Pull a string and check the path allowing a wilcard - provide for error return.
****************************************************************************/
size_t srvstr_get_path_wcard(char *inbuf, char *dest, const char *src, size_t dest_len, size_t src_len, int flags,
NTSTATUS *err, BOOL *contains_wcard)
size_t srvstr_get_path_wcard(char *inbuf, uint16 smb_flags2, char *dest,
const char *src, size_t dest_len, size_t src_len,
int flags, NTSTATUS *err, BOOL *contains_wcard)
{
size_t ret;
#ifdef DEVELOPER
@ -218,10 +219,10 @@ size_t srvstr_get_path_wcard(char *inbuf, char *dest, const char *src, size_t de
#endif
if (src_len == 0) {
ret = srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), dest, src,
ret = srvstr_pull_buf(inbuf, smb_flags2, dest, src,
dest_len, flags);
} else {
ret = srvstr_pull(inbuf, SVAL(inbuf, smb_flg2), dest, src,
ret = srvstr_pull(inbuf, smb_flags2, dest, src,
dest_len, src_len, flags);
}
@ -249,7 +250,9 @@ size_t srvstr_get_path_wcard(char *inbuf, char *dest, const char *src, size_t de
Pull a string and check the path - provide for error return.
****************************************************************************/
size_t srvstr_get_path(char *inbuf, char *dest, const char *src, size_t dest_len, size_t src_len, int flags, NTSTATUS *err)
size_t srvstr_get_path(char *inbuf, uint16 smb_flags2, char *dest,
const char *src, size_t dest_len, size_t src_len,
int flags, NTSTATUS *err)
{
size_t ret;
#ifdef DEVELOPER
@ -257,14 +260,14 @@ size_t srvstr_get_path(char *inbuf, char *dest, const char *src, size_t dest_len
#endif
if (src_len == 0) {
ret = srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), dest, src,
ret = srvstr_pull_buf(inbuf, smb_flags2, dest, src,
dest_len, flags);
} else {
ret = srvstr_pull(inbuf, SVAL(inbuf, smb_flg2), dest, src,
ret = srvstr_pull(inbuf, smb_flags2, dest, src,
dest_len, src_len, flags);
}
if (SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) {
if (smb_flags2 & FLAGS2_DFS_PATHNAMES) {
/*
* For a DFS path the function parse_dfs_path()
* will do the path processing, just make a copy.
@ -681,7 +684,8 @@ int reply_checkpath(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
START_PROFILE(SMBcheckpath);
srvstr_get_path(inbuf, name, smb_buf(inbuf) + 1, sizeof(name), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), name, smb_buf(inbuf) + 1,
sizeof(name), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcheckpath);
status = map_checkpath_error(inbuf, status);
@ -768,7 +772,8 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
START_PROFILE(SMBgetatr);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path(inbuf, fname, p, sizeof(fname), 0, STR_TERMINATE, &status);
p += srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, p,
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBgetatr);
return ERROR_NT(status);
@ -854,7 +859,8 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
START_PROFILE(SMBsetatr);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path(inbuf, fname, p, sizeof(fname), 0, STR_TERMINATE, &status);
p += srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, p,
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBsetatr);
return ERROR_NT(status);
@ -1016,7 +1022,9 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
maxentries = SVAL(inbuf,smb_vwv0);
dirtype = SVAL(inbuf,smb_vwv1);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path_wcard(inbuf, path, p, sizeof(path), 0, STR_TERMINATE, &nt_status, &mask_contains_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), path, p,
sizeof(path), 0, STR_TERMINATE, &nt_status,
&mask_contains_wcard);
if (!NT_STATUS_IS_OK(nt_status)) {
END_PROFILE(SMBsearch);
return ERROR_NT(nt_status);
@ -1221,7 +1229,9 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
outsize = set_message(inbuf,outbuf,1,0,True);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path_wcard(inbuf, path, p, sizeof(path), 0, STR_TERMINATE, &err, &path_contains_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), path, p,
sizeof(path), 0, STR_TERMINATE, &err,
&path_contains_wcard);
if (!NT_STATUS_IS_OK(err)) {
END_PROFILE(SMBfclose);
return ERROR_NT(err);
@ -1280,7 +1290,8 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
deny_mode = SVAL(inbuf,smb_vwv0);
srvstr_get_path(inbuf, fname, smb_buf(inbuf)+1, sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, smb_buf(inbuf)+1,
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBopen);
return ERROR_NT(status);
@ -1414,7 +1425,8 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
}
/* XXXX we need to handle passed times, sattr and flags */
srvstr_get_path(inbuf, fname, smb_buf(inbuf), sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, smb_buf(inbuf),
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBopenX);
return ERROR_NT(status);
@ -1602,7 +1614,8 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
ts[1] = convert_time_t_to_timespec(srv_make_unix_date3(inbuf + smb_vwv1)); /* mtime. */
srvstr_get_path(inbuf, fname, smb_buf(inbuf) + 1, sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, smb_buf(inbuf) + 1,
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcreate);
return ERROR_NT(status);
@ -1703,7 +1716,8 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
init_smb_request(&req, (uint8 *)inbuf);
srvstr_get_path(inbuf, fname, smb_buf(inbuf)+1, sizeof(fname), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, smb_buf(inbuf)+1,
sizeof(fname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBctemp);
return ERROR_NT(status);
@ -2111,7 +2125,9 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
dirtype = SVAL(inbuf,smb_vwv0);
srvstr_get_path_wcard(inbuf, name, smb_buf(inbuf) + 1, sizeof(name), 0, STR_TERMINATE, &status, &path_contains_wcard);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), name,
smb_buf(inbuf) + 1, sizeof(name), 0,
STR_TERMINATE, &status, &path_contains_wcard);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBunlink);
return ERROR_NT(status);
@ -3834,7 +3850,9 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
START_PROFILE(SMBmkdir);
srvstr_get_path(inbuf, directory, smb_buf(inbuf) + 1, sizeof(directory), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), directory,
smb_buf(inbuf) + 1, sizeof(directory), 0,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBmkdir);
return ERROR_NT(status);
@ -4075,7 +4093,9 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
NTSTATUS status;
START_PROFILE(SMBrmdir);
srvstr_get_path(inbuf, directory, smb_buf(inbuf) + 1, sizeof(directory), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), directory,
smb_buf(inbuf) + 1, sizeof(directory), 0,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBrmdir);
return ERROR_NT(status);
@ -4765,13 +4785,17 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
init_smb_request(&req, (uint8 *)inbuf);
p = smb_buf(inbuf) + 1;
p += srvstr_get_path_wcard(inbuf, name, p, sizeof(name), 0, STR_TERMINATE, &status, &src_has_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), name, p,
sizeof(name), 0, STR_TERMINATE, &status,
&src_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBmv);
return ERROR_NT(status);
}
p++;
p += srvstr_get_path_wcard(inbuf, newname, p, sizeof(newname), 0, STR_TERMINATE, &status, &dest_has_wcard);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), newname, p,
sizeof(newname), 0, STR_TERMINATE, &status,
&dest_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBmv);
return ERROR_NT(status);
@ -4960,12 +4984,16 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
*directory = *mask = 0;
p = smb_buf(inbuf);
p += srvstr_get_path_wcard(inbuf, name, p, sizeof(name), 0, STR_TERMINATE, &status, &source_has_wild);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), name, p,
sizeof(name), 0, STR_TERMINATE, &status,
&source_has_wild);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcopy);
return ERROR_NT(status);
}
p += srvstr_get_path_wcard(inbuf, newname, p, sizeof(newname), 0, STR_TERMINATE, &status, &dest_has_wild);
p += srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), newname, p,
sizeof(newname), 0, STR_TERMINATE, &status,
&dest_has_wild);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcopy);
return ERROR_NT(status);
@ -5181,7 +5209,9 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
return ERROR_DOS(ERRDOS,ERRnoaccess);
}
srvstr_get_path(inbuf, newdir, smb_buf(inbuf) + 1, sizeof(newdir), 0, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), newdir,
smb_buf(inbuf) + 1, sizeof(newdir), 0, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(pathworks_setdir);
return ERROR_NT(status);

View File

@ -804,7 +804,9 @@ static int call_trans2open(connection_struct *conn,
return(ERROR_DOS(ERRSRV,ERRaccess));
}
srvstr_get_path(inbuf, fname, pname, sizeof(fname), total_params - 28, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, pname,
sizeof(fname), total_params - 28, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -1747,7 +1749,9 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
return ERROR_NT(NT_STATUS_INVALID_LEVEL);
}
srvstr_get_path_wcard(inbuf, directory, params+12, sizeof(directory), total_params - 12, STR_TERMINATE, &ntstatus, &mask_contains_wcard);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), directory,
params+12, sizeof(directory), total_params - 12,
STR_TERMINATE, &ntstatus, &mask_contains_wcard);
if (!NT_STATUS_IS_OK(ntstatus)) {
return ERROR_NT(ntstatus);
}
@ -2012,7 +2016,10 @@ static int call_trans2findnext(connection_struct *conn, char *inbuf, char *outbu
*mask = *directory = *resume_name = 0;
srvstr_get_path_wcard(inbuf, resume_name, params+12, sizeof(resume_name), total_params - 12, STR_TERMINATE, &ntstatus, &mask_contains_wcard);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), resume_name,
params+12, sizeof(resume_name),
total_params - 12, STR_TERMINATE, &ntstatus,
&mask_contains_wcard);
if (!NT_STATUS_IS_OK(ntstatus)) {
/* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to
complain (it thinks we're asking for the directory above the shared
@ -3401,7 +3408,9 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
return ERROR_NT(NT_STATUS_INVALID_LEVEL);
}
srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), total_params - 6, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, &params[6],
sizeof(fname), total_params - 6,
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -4587,7 +4596,8 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), total_data, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), oldname, pdata,
sizeof(oldname), total_data, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@ -4637,7 +4647,9 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
srvstr_get_path_wcard(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status, &dest_has_wcard);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), newname, &pdata[12],
sizeof(newname), len, 0, &status,
&dest_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@ -5850,7 +5862,9 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
}
info_level = SVAL(params,0);
srvstr_get_path(inbuf, fname, &params[6], sizeof(fname), total_params - 6, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), fname, &params[6],
sizeof(fname), total_params - 6, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
@ -6188,7 +6202,9 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
}
srvstr_get_path(inbuf, directory, &params[4], sizeof(directory), total_params - 4, STR_TERMINATE, &status);
srvstr_get_path(inbuf, SVAL(inbuf,smb_flg2), directory, &params[4],
sizeof(directory), total_params - 4, STR_TERMINATE,
&status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}