From d45865ad8d1e9ec1ca0681b9adf1b7646438117a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Aug 2012 12:46:50 -0700 Subject: [PATCH 1/2] Fix bug in SMB_FIND_INFO_STANDARD parsing found by Volker. The function align_string() is now broken as base_ptr no longer points at the start of the SMB data packet, but at the start of the returned TRANS2 data area. Replace it with a check for FLAGS2_UNICODE_STRINGS and a call to ucs2_align(). --- source3/libsmb/clilist.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 43fa7d7..6276d05 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -86,7 +86,9 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, finfo->mode = CVAL(p,24); len = CVAL(p, 26); p += 27; - p += align_string(base_ptr, p, 0); + if (recv_flags2 & FLAGS2_UNICODE_STRINGS) { + p += ucs2_align(base_ptr, p, STR_UNICODE); + } /* We can safely use len here (which is required by OS/2) * and the NAS-BASIC server instead of +2 or +1 as the -- 1.7.7.3 From adf7c60f5396605e439ff62b5a1fca5765cada64 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Aug 2012 12:52:26 -0700 Subject: [PATCH 2/2] Remove align_string() and clistr_align_out(). No longer used. --- source3/include/proto.h | 2 -- source3/lib/charcnv.c | 12 ------------ source3/libsmb/clistr.c | 5 ----- source3/libsmb/proto.h | 2 -- 4 files changed, 0 insertions(+), 21 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 720f431..47e8a66 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -137,8 +137,6 @@ size_t pull_string_talloc_fn(const char *function, const void *src, size_t src_len, int flags); -size_t align_string(const void *base_ptr, const char *p, int flags); - /* The following definitions come from lib/clobber.c */ void clobber_region(const char *fn, unsigned int line, char *dest, size_t len); diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index d3f65ca..6f52f97 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -1688,15 +1688,3 @@ size_t pull_string_talloc_fn(const char *function, src_len, flags); } - - -size_t align_string(const void *base_ptr, const char *p, int flags) -{ - if (!(flags & STR_ASCII) && \ - ((flags & STR_UNICODE || \ - (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) { - return ucs2_align(base_ptr, p, flags); - } - return 0; -} - diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 6e45799..ad22c8c 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -86,8 +86,3 @@ size_t clistr_pull_talloc_fn(const char *function, src_len, flags); } - -size_t clistr_align_out(struct cli_state *cli, const void *p, int flags) -{ - return align_string(cli->outbuf, (const char *)p, flags); -} diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 3b917a1..828c140 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -781,8 +781,6 @@ size_t clistr_pull_talloc_fn(const char *function, const void *src, int src_len, int flags); -size_t clistr_align_out(struct cli_state *cli, const void *p, int flags); - /* The following definitions come from libsmb/clitrans.c */ struct tevent_req *cli_trans_send( -- 1.7.7.3