diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-03-13 22:00:46 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-03-13 22:00:46 +0000 |
commit | ff0462cde830a306105b9d585a36239f27e38f23 (patch) | |
tree | b5ea32e1e92328472c685982be2118740f162636 /source3/smbd | |
parent | e532d96a26055d23450bfb3e9c28e0179ee9f2d2 (diff) | |
download | samba-ff0462cde830a306105b9d585a36239f27e38f23.tar.gz samba-ff0462cde830a306105b9d585a36239f27e38f23.tar.bz2 samba-ff0462cde830a306105b9d585a36239f27e38f23.zip |
simpler and more correct srvstr_push()
it now uses outbuf not inbuf for the unicode flag, which
allows for some server fns to be ascii and means one less
parameter in push calls
(This used to be commit a6dd6662267eeddf368ff0ffba76b45761bf4eeb)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/reply.c | 12 | ||||
-rw-r--r-- | source3/smbd/srvstr.c | 20 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 18 |
3 files changed, 25 insertions, 25 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 230b3db750..96192f0575 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -320,7 +320,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt if (Protocol < PROTOCOL_NT1) { set_message(outbuf,2,0,True); p = smb_buf(outbuf); - p += srvstr_push(inbuf, outbuf, p, devicename, -1, + p += srvstr_push(outbuf, p, devicename, -1, STR_CONVERT|STR_TERMINATE|STR_ASCII); set_message_end(outbuf,p); } else { @@ -330,9 +330,9 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt set_message(outbuf,3,0,True); p = smb_buf(outbuf); - p += srvstr_push(inbuf, outbuf, p, devicename, -1, + p += srvstr_push(outbuf, p, devicename, -1, STR_CONVERT|STR_TERMINATE|STR_ASCII); - p += srvstr_push(inbuf, outbuf, p, fsname, -1, + p += srvstr_push(outbuf, p, fsname, -1, STR_CONVERT|STR_TERMINATE); set_message_end(outbuf,p); @@ -1013,9 +1013,9 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int char *p; set_message(outbuf,3,0,True); p = smb_buf(outbuf); - p += srvstr_push(inbuf, outbuf, p, "Unix", -1, STR_TERMINATE|STR_CONVERT); - p += srvstr_push(inbuf, outbuf, p, "Samba", -1, STR_TERMINATE|STR_CONVERT); - p += srvstr_push(inbuf, outbuf, p, global_myworkgroup, -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_push(outbuf, p, "Unix", -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_push(outbuf, p, "Samba", -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_TERMINATE|STR_CONVERT); set_message_end(outbuf,p); /* perhaps grab OS version here?? */ } diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c index b944ed2578..c3eef46440 100644 --- a/source3/smbd/srvstr.c +++ b/source3/smbd/srvstr.c @@ -23,7 +23,7 @@ #include "includes.h" -#define UNICODE_FLAG() (SVAL(inbuf, smb_flg2) & FLAGS2_UNICODE_STRINGS) +#define UNICODE_FLAG(buf) (SVAL(buf, smb_flg2) & FLAGS2_UNICODE_STRINGS) /**************************************************************************** copy a string from a char* src to a unicode or ascii @@ -38,7 +38,7 @@ flags can have: dest_len is the maximum length allowed in the destination. If dest_len is -1 then no maxiumum is used ****************************************************************************/ -int srvstr_push(void *inbuf, void *outbuf, void *dest, const char *src, int dest_len, int flags) +int srvstr_push(void *outbuf, void *dest, const char *src, int dest_len, int flags) { int len=0; @@ -47,14 +47,14 @@ int srvstr_push(void *inbuf, void *outbuf, void *dest, const char *src, int dest dest_len = sizeof(pstring); } - if (!(flags & STR_ASCII) && srvstr_align(inbuf, PTR_DIFF(dest, outbuf))) { + if (!(flags & STR_ASCII) && srvstr_align(outbuf, PTR_DIFF(dest, outbuf))) { *(char *)dest = 0; dest++; dest_len--; len++; } - if ((flags & STR_ASCII) || !UNICODE_FLAG()) { + if ((flags & STR_ASCII) || !UNICODE_FLAG(outbuf)) { /* the client doesn't want unicode */ safe_strcpy(dest, src, dest_len); len = strlen(dest); @@ -86,14 +86,14 @@ return the length that a string would occupy when copied with srvstr_push() STR_UPPER means uppercase in the destination note that dest is only used for alignment purposes. No data is written. ****************************************************************************/ -int srvstr_push_size(void *inbuf, void *outbuf, +int srvstr_push_size(void *outbuf, const void *dest, const char *src, int dest_len, int flags) { int len = strlen(src); if (flags & STR_TERMINATE) len++; - if (!(flags & STR_ASCII) && UNICODE_FLAG()) len *= 2; + if (!(flags & STR_ASCII) && UNICODE_FLAG(outbuf)) len *= 2; - if (!(flags & STR_ASCII) && dest && srvstr_align(inbuf, PTR_DIFF(outbuf, dest))) { + if (!(flags & STR_ASCII) && dest && srvstr_align(outbuf, PTR_DIFF(outbuf, dest))) { len++; } @@ -124,7 +124,7 @@ int srvstr_pull(void *inbuf, char *dest, const void *src, int dest_len, int src_ if (src_len > 0) src_len--; } - if ((flags & STR_ASCII) || (!(flags & STR_UNICODE) && !UNICODE_FLAG())) { + if ((flags & STR_ASCII) || (!(flags & STR_UNICODE) && !UNICODE_FLAG(inbuf))) { /* the server doesn't want unicode */ if (flags & STR_TERMINATE) { safe_strcpy(dest, src, dest_len); @@ -168,7 +168,7 @@ int srvstr_pull_size(void *inbuf, const void *src, int src_len) if (src_len > 0) src_len--; } - if (!UNICODE_FLAG()) { + if (!UNICODE_FLAG(inbuf)) { return strlen(src); } return strlen_w(src); @@ -181,6 +181,6 @@ otherwise return 1 if offset is off ****************************************************************************/ int srvstr_align(void *inbuf, int offset) { - if (!UNICODE_FLAG()) return 0; + if (!UNICODE_FLAG(inbuf)) return 0; return offset & 1; } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index a16dcc3e19..714d42ce2a 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -463,7 +463,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SSVAL(p,l1_attrFile,mode); p += l1_achName; nameptr = p; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SCVAL(p, -1, len); p += len; @@ -484,7 +484,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SIVAL(p,l2_cbList,0); /* No extended attributes */ p += l2_achName; nameptr = p; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SCVAL(p, -1, len); p += len; @@ -501,7 +501,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SIVAL(p,26,4); p += 31; nameptr = p; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SCVAL(p, -1, len); p += len; @@ -521,7 +521,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SSVAL(p,24,mode); p += 33; nameptr = p; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SCVAL(p, -1, len); p += len; @@ -548,7 +548,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, pstrcpy(mangled_name, fname); name_map_mangle(mangled_name,True,True,SNUM(conn)); mangled_name[12] = 0; - len = srvstr_push(inbuf, outbuf, p+2, mangled_name, 24, + len = srvstr_push(outbuf, p+2, mangled_name, 24, STR_CONVERT|STR_UPPER); SSVAL(p, 0, len); } else { @@ -556,7 +556,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, *(p+2) = 0; } p += 2 + 24; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SIVAL(q,0,len); p += len; @@ -578,7 +578,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 16; SIVAL(p,0,nt_extmode); p += 4; p += 4; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SIVAL(p, -4, len); p += len; @@ -603,7 +603,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 4; SIVAL(p,0,0); p += 4; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SIVAL(p, -4, len); p += len; @@ -618,7 +618,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 4; SIVAL(p,0,reskey); p += 4; p += 4; - len = srvstr_push(inbuf, outbuf, p, fname, -1, + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE|STR_CONVERT); SIVAL(p, -4, len); p += len; |