The branch, master has been updated via a01cb7b4476 winbindd: Remove a "wrong" error message via 6dfc58624e5 lib: Slightly simplify is_ntfs_stream_smb_fname() via b3c2d5d4b6b vfs: Remove a typedef via 38e5b39eac9 smbd: Fix a typo via a395f752f07 smbd: Fix CID 1504457 Resource leak via f236c42fb70 smbd: Remove NTCREATEX_FLAG_DELETE_ON_CLOSE via 540d4ae6b99 lsa_server4: Simplify get_tdo() with talloc_asprintf_addbuf() via 49b3bbdead7 lsa_server4: Simplify get_tdo() with dom_sid_str_buf() via 777597d0c65 smbd: Move message_push_string() to smb1_utils.c via 9ec99ab57ca smbd: Remove unused smb_bufrem() macro from 7ba732bac12 s3:smbd implement volume serial number parameter
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a01cb7b44761102f63cb2c7bb009bf1e8b4ebe05 Author: Volker Lendecke <v...@samba.org> Date: Sun Jun 5 17:28:04 2022 +0200 winbindd: Remove a "wrong" error message Before 9bacf7529dd child_process_request() returned right after the callback function without going through the DEBUG message. Restore that behaviour. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Mon Jun 6 20:17:06 UTC 2022 on sn-devel-184 commit 6dfc58624e5b704507d3316be429be4868b202e2 Author: Volker Lendecke <v...@samba.org> Date: Sun Jun 5 14:39:48 2022 +0200 lib: Slightly simplify is_ntfs_stream_smb_fname() YMMV, but for me the direct return is easier to read Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit b3c2d5d4b6bfce64e0243c1056076ab9a1b61fea Author: Volker Lendecke <v...@samba.org> Date: Fri Jun 3 14:47:30 2022 +0200 vfs: Remove a typedef We want to get rid of struct typedefs, and this was quick Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 38e5b39eac98b874a80f8fbb741c4bc8d9001614 Author: Volker Lendecke <v...@samba.org> Date: Thu Jun 2 15:48:37 2022 +0200 smbd: Fix a typo Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a395f752f0748751d4ade533c41066903f26c2dd Author: Volker Lendecke <v...@samba.org> Date: Fri May 20 10:18:59 2022 +0200 smbd: Fix CID 1504457 Resource leak Highly likely that's a false positive because Coverity does not understand that srv_encrypt_buffer() only allocates when NT_STATUS_OK(status), but it does not hurt to make it happy this way. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit f236c42fb703818a72ddba83a56133f94677c7d6 Author: Volker Lendecke <v...@samba.org> Date: Thu May 19 20:05:52 2022 +0200 smbd: Remove NTCREATEX_FLAG_DELETE_ON_CLOSE This is only used for print files. Storing it in the fd_handle seems overkill to me, this can easily be stored directly in the fsp itself, we have a flag for this. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 540d4ae6b99278e1346caab6ac2bbabd29492222 Author: Volker Lendecke <v...@samba.org> Date: Fri May 27 20:57:53 2022 +0200 lsa_server4: Simplify get_tdo() with talloc_asprintf_addbuf() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 49b3bbdead787adf99e5187ede0fc0384af62311 Author: Volker Lendecke <v...@samba.org> Date: Fri May 27 18:38:34 2022 +0200 lsa_server4: Simplify get_tdo() with dom_sid_str_buf() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 777597d0c65b3cb735dc3db2a61f91e233551938 Author: Volker Lendecke <v...@samba.org> Date: Sun Jun 5 16:44:28 2022 +0200 smbd: Move message_push_string() to smb1_utils.c Only used in SMB1 code Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9ec99ab57cac80ecb5e4932c44a6d3a568c62f08 Author: Volker Lendecke <v...@samba.org> Date: Sun Jun 5 16:37:13 2022 +0200 smbd: Remove unused smb_bufrem() macro Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/smb.h | 3 -- source3/include/smb_macros.h | 1 - source3/include/vfs.h | 4 +-- source3/lib/filename_util.c | 6 +--- source3/modules/vfs_ceph.c | 4 +-- source3/modules/vfs_default.c | 4 +-- source3/printing/printspoolss.c | 4 +-- source3/smbd/fd_handle.c | 6 +--- source3/smbd/proto.h | 3 +- source3/smbd/smb1_process.c | 5 +++- source3/smbd/smb1_reply.c | 6 ++-- source3/smbd/smb1_trans2.c | 8 ++---- source3/smbd/smb1_utils.c | 55 +++++++++++++++++++++++++++++++++++++ source3/smbd/smb1_utils.h | 2 ++ source3/smbd/smb2_setinfo.c | 5 +--- source3/smbd/smb2_trans2.c | 2 +- source3/smbd/srvstr.c | 55 ------------------------------------- source3/smbd/statvfs.c | 4 +-- source3/winbindd/winbindd_dual.c | 4 --- source4/rpc_server/lsa/dcesrv_lsa.c | 38 +++++++------------------ 20 files changed, 92 insertions(+), 127 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/smb.h b/source3/include/smb.h index 90105e00b14..6363bdc0c93 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -407,9 +407,6 @@ Offset Data length. #define NTCREATEX_FLAG_DENY_DOS 0x0001 #define NTCREATEX_FLAG_DENY_FCB 0x0002 -/* Private flag for printer support */ -#define NTCREATEX_FLAG_DELETE_ON_CLOSE 0x0008 - /* Private flag for streams support */ #define NTCREATEX_FLAG_STREAM_BASEOPEN 0x0010 diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 344a997cbd2..85ef221ed18 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -151,7 +151,6 @@ #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) /* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */ -#define smb_bufrem(buf, p) (smb_buflen(buf)-PTR_DIFF(p, smb_buf(buf))) #define smbreq_bufrem(req, p) (req->buflen - PTR_DIFF(p, req->buf)) diff --git a/source3/include/vfs.h b/source3/include/vfs.h index ac6a3017f80..be4712689eb 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -1313,7 +1313,7 @@ typedef struct vfs_handle_struct { } vfs_handle_struct; -typedef struct vfs_statvfs_struct { +struct vfs_statvfs_struct { /* For undefined recommended transfer size return -1 in that field */ uint32_t OptimalTransferSize; /* bsize on some os, iosize on other os */ uint32_t BlockSize; @@ -1340,7 +1340,7 @@ typedef struct vfs_statvfs_struct { /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ int FsCapabilities; -} vfs_statvfs_struct; +}; /* Add a new FSP extension of the given type. Returns a pointer to the * extenstion data. diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index ca4d77713ad..1ba8fceb6e0 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -290,11 +290,7 @@ bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname) { assert_valid_stream_smb_fname(smb_fname); - if (smb_fname->stream_name == NULL) { - return false; - } - - return true; + return (smb_fname->stream_name != NULL); } /**************************************************************************** diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 8132f5ba8b1..14582905212 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -263,8 +263,8 @@ static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_ } static int cephwrap_statvfs(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - vfs_statvfs_struct *statbuf) + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf) { struct statvfs statvfs_buf; int ret; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index d67a9fe4325..8e6cbfd3707 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -117,8 +117,8 @@ static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, } static int vfswrap_statvfs(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - vfs_statvfs_struct *statbuf) + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf) { return sys_statvfs(smb_fname->base_name, statbuf); } diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c index f02f584ad48..31117a4b743 100644 --- a/source3/printing/printspoolss.c +++ b/source3/printing/printspoolss.c @@ -243,6 +243,7 @@ NTSTATUS print_spool_open(files_struct *fsp, fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->fsp_flags.is_directory = false; + fsp->fsp_flags.delete_on_close = false; fsp->print_file = pf; @@ -319,8 +320,7 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type) WERROR werr; struct dcerpc_binding_handle *b = NULL; - if (fh_get_private_options(fsp->fh) & - NTCREATEX_FLAG_DELETE_ON_CLOSE) { + if (fsp->fsp_flags.delete_on_close) { int ret; /* diff --git a/source3/smbd/fd_handle.c b/source3/smbd/fd_handle.c index e599181fe6b..87472909787 100644 --- a/source3/smbd/fd_handle.c +++ b/source3/smbd/fd_handle.c @@ -28,11 +28,7 @@ struct fd_handle { /* * NT Create options, but we only look at * NTCREATEX_FLAG_DENY_DOS and - * NTCREATEX_FLAG_DENY_FCB and - * NTCREATEX_FLAG_DELETE_ON_CLOSE - * for print files *only*, where - * DELETE_ON_CLOSE is not stored in the share - * mode database. + * NTCREATEX_FLAG_DENY_FCB. */ uint32_t private_options; uint64_t gen_id; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 9917562d1de..166317f7965 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1081,7 +1081,6 @@ bool is_share_read_only_for_token(const char *username, NTSTATUS srvstr_push_fn(const char *base_ptr, uint16_t smb_flags2, void *dest, const char *src, int dest_len, int flags, size_t *ret_len); -ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags); /* The following definitions come from smbd/statcache.c */ @@ -1104,7 +1103,7 @@ bool reset_stat_cache( void ); /* The following definitions come from smbd/statvfs.c */ -int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf); +int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf); /* The following definitions come from smbd/trans2.c */ diff --git a/source3/smbd/smb1_process.c b/source3/smbd/smb1_process.c index c041b48d88d..140884adb96 100644 --- a/source3/smbd/smb1_process.c +++ b/source3/smbd/smb1_process.c @@ -238,14 +238,17 @@ bool smb1_srv_send(struct smbXsrv_connection *xconn, char *buffer, } if (do_encrypt) { - NTSTATUS status = srv_encrypt_buffer(xconn, buffer, &buf_out); + char *enc = NULL; + NTSTATUS status = srv_encrypt_buffer(xconn, buffer, &enc); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("send_smb: SMB encryption failed " "on outgoing packet! Error %s\n", nt_errstr(status) )); + SAFE_FREE(enc); ret = -1; goto out; } + buf_out = enc; } len = smb_len_large(buf_out) + 4; diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index ec774e23ee3..140d03242c3 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -665,8 +665,10 @@ void reply_getatr(struct smb_request *req) goto out; } - /* dos smetimes asks for a stat of "" - it returns a "hidden directory" - under WfWg - weird! */ + /* + * dos sometimes asks for a stat of "" - it returns a "hidden + * directory" under WfWg - weird! + */ if (*fname == '\0') { mode = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; if (!CAN_WRITE(conn)) { diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index ea11788c783..8c3bafa3a00 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -2415,12 +2415,8 @@ static void call_trans2setfilepathinfo(connection_struct *conn, * Doing a DELETE_ON_CLOSE should cancel a print job. */ if ((info_level == SMB_SET_FILE_DISPOSITION_INFO) && CVAL(pdata,0)) { - uint32_t new_private_options = - fh_get_private_options(fsp->fh); - new_private_options |= - NTCREATEX_FLAG_DELETE_ON_CLOSE; - fh_set_private_options(fsp->fh, - new_private_options); + + fsp->fsp_flags.delete_on_close = true; DEBUG(3,("call_trans2setfilepathinfo: " "Cancelling print job (%s)\n", diff --git a/source3/smbd/smb1_utils.c b/source3/smbd/smb1_utils.c index 15afc3f5ef9..5092aa51929 100644 --- a/source3/smbd/smb1_utils.c +++ b/source3/smbd/smb1_utils.c @@ -121,3 +121,58 @@ bool send_keepalive(int client) return(write_data(client,(char *)buf,4) == 4); } + +/******************************************************************* + Add a string to the end of a smb_buf, adjusting bcc and smb_len. + Return the bytes added +********************************************************************/ + +ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags) +{ + size_t buf_size = smb_len(*outbuf) + 4; + size_t grow_size; + size_t result = 0; + uint8_t *tmp; + NTSTATUS status; + + /* + * We need to over-allocate, now knowing what srvstr_push will + * actually use. This is very generous by incorporating potential + * padding, the terminating 0 and at most 4 chars per UTF-16 code + * point. + */ + grow_size = (strlen(str) + 2) * 4; + + if (!(tmp = talloc_realloc(NULL, *outbuf, uint8_t, + buf_size + grow_size))) { + DEBUG(0, ("talloc failed\n")); + return -1; + } + + status = srvstr_push((char *)tmp, SVAL(tmp, smb_flg2), + tmp + buf_size, str, grow_size, flags, &result); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("srvstr_push failed\n")); + return -1; + } + + /* + * Ensure we clear out the extra data we have + * grown the buffer by, but not written to. + */ + if (buf_size + result < buf_size) { + return -1; + } + if (grow_size < result) { + return -1; + } + + memset(tmp + buf_size + result, '\0', grow_size - result); + + set_message_bcc((char *)tmp, smb_buflen(tmp) + result); + + *outbuf = tmp; + + return result; +} diff --git a/source3/smbd/smb1_utils.h b/source3/smbd/smb1_utils.h index 2416a91148a..6f791e2ff80 100644 --- a/source3/smbd/smb1_utils.h +++ b/source3/smbd/smb1_utils.h @@ -25,6 +25,7 @@ #include "includes.h" #include "vfs.h" #include "proto.h" +#include "lib/util/string_wrappers.h" struct files_struct *fcb_or_dos_open( struct smb_request *req, @@ -33,5 +34,6 @@ struct files_struct *fcb_or_dos_open( uint32_t create_options, uint32_t private_flags); bool send_keepalive(int client); +ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags); #endif diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index d3c3ba63d6b..04fd9490fe9 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -439,10 +439,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, if ((file_info_level == SMB_SET_FILE_DISPOSITION_INFO) && in_input_buffer.length >= 1 && CVAL(in_input_buffer.data,0)) { - uint32_t new_private_options = - fh_get_private_options(fsp->fh); - new_private_options |= NTCREATEX_FLAG_DELETE_ON_CLOSE; - fh_set_private_options(fsp->fh, new_private_options); + fsp->fsp_flags.delete_on_close = true; DEBUG(3,("smbd_smb2_setinfo_send: " "Cancelling print job (%s)\n", diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 77bcfe33e13..cc6dc3adcf7 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -2599,7 +2599,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned case SMB_QUERY_POSIX_FS_INFO: { int rc; - vfs_statvfs_struct svfs; + struct vfs_statvfs_struct svfs; if (!lp_smb1_unix_extensions()) { return NT_STATUS_INVALID_LEVEL; diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c index 6ea3ea48a59..5298ea735b3 100644 --- a/source3/smbd/srvstr.c +++ b/source3/smbd/srvstr.c @@ -76,58 +76,3 @@ NTSTATUS srvstr_push_fn(const char *base_ptr, uint16_t smb_flags2, void *dest, } return status; } - -/******************************************************************* - Add a string to the end of a smb_buf, adjusting bcc and smb_len. - Return the bytes added -********************************************************************/ - -ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags) -{ - size_t buf_size = smb_len(*outbuf) + 4; - size_t grow_size; - size_t result = 0; - uint8_t *tmp; - NTSTATUS status; - - /* - * We need to over-allocate, now knowing what srvstr_push will - * actually use. This is very generous by incorporating potential - * padding, the terminating 0 and at most 4 chars per UTF-16 code - * point. - */ - grow_size = (strlen(str) + 2) * 4; - - if (!(tmp = talloc_realloc(NULL, *outbuf, uint8_t, - buf_size + grow_size))) { - DEBUG(0, ("talloc failed\n")); - return -1; - } - - status = srvstr_push((char *)tmp, SVAL(tmp, smb_flg2), - tmp + buf_size, str, grow_size, flags, &result); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("srvstr_push failed\n")); - return -1; - } - - /* - * Ensure we clear out the extra data we have - * grown the buffer by, but not written to. - */ - if (buf_size + result < buf_size) { - return -1; - } - if (grow_size < result) { - return -1; - } - - memset(tmp + buf_size + result, '\0', grow_size - result); - - set_message_bcc((char *)tmp, smb_buflen(tmp) + result); - - *outbuf = tmp; - - return result; -} diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index aca6752c7fb..981e7a5ba79 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -115,7 +115,7 @@ static int bsd_statvfs(const char *path, vfs_statvfs_struct *statbuf) return ret; } #elif defined(STAT_STATVFS) && defined(HAVE_FSID_INT) -static int posix_statvfs(const char *path, vfs_statvfs_struct *statbuf) +static int posix_statvfs(const char *path, struct vfs_statvfs_struct *statbuf) { struct statvfs statvfs_buf; int result; @@ -164,7 +164,7 @@ static int posix_statvfs(const char *path, vfs_statvfs_struct *statbuf) between LSB and FreeBSD/POSIX.1 (IEEE Std 1003.1-2001) we need to abstract the interface so that particular OS would use its preferred interface. */ -int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) +int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf) { #if defined(BSD_STYLE_STATVFS) return bsd_statvfs(path, statbuf); diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 75ecdf53968..fe855045fa8 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -773,10 +773,6 @@ static void child_process_request(struct winbindd_child *child, /* Process command */ state->response->result = winbindd_dual_ndrcmd(domain, state); - - DEBUG(1, ("child_process_request: unknown request fn number %d\n", - (int)state->request->cmd)); - state->response->result = WINBINDD_ERROR; } void setup_child(struct winbindd_domain *domain, struct winbindd_child *child, diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 4101d6ddd34..185e0044de1 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1673,7 +1673,6 @@ static NTSTATUS get_tdo(struct ldb_context *sam, TALLOC_CTX *mem_ctx, }; char *dns = NULL; char *nbn = NULL; - char *sidstr = NULL; char *filter; int ret; @@ -1685,49 +1684,32 @@ static NTSTATUS get_tdo(struct ldb_context *sam, TALLOC_CTX *mem_ctx, filter = talloc_strdup(mem_ctx, "(objectclass=trustedDomain)"); } - if (!filter) { - return NT_STATUS_NO_MEMORY; - } if (dns_domain) { dns = ldb_binary_encode_string(mem_ctx, dns_domain); if (!dns) { return NT_STATUS_NO_MEMORY; } - filter = talloc_asprintf_append(filter, - "(trustPartner=%s)", dns); - if (!filter) { - return NT_STATUS_NO_MEMORY; - } + talloc_asprintf_addbuf(&filter, "(trustPartner=%s)", dns); } if (netbios) { nbn = ldb_binary_encode_string(mem_ctx, netbios); if (!nbn) { return NT_STATUS_NO_MEMORY; } - filter = talloc_asprintf_append(filter, - "(flatname=%s)", nbn); - if (!filter) { - return NT_STATUS_NO_MEMORY; - } + talloc_asprintf_addbuf(&filter, "(flatname=%s)", nbn); } if (sid) { - sidstr = dom_sid_string(mem_ctx, sid); - if (!sidstr) { - return NT_STATUS_INVALID_PARAMETER; - } - filter = talloc_asprintf_append(filter, - "(securityIdentifier=%s)", - sidstr); - if (!filter) { - return NT_STATUS_NO_MEMORY; - } + struct dom_sid_buf buf; + char *sidstr = dom_sid_str_buf(sid, &buf); + talloc_asprintf_addbuf( + &filter, "(securityIdentifier=%s)", sidstr); } if (dns_domain || netbios || sid) { - filter = talloc_asprintf_append(filter, "))"); - if (!filter) { - return NT_STATUS_NO_MEMORY; - } + talloc_asprintf_addbuf(&filter, "))"); + } + if (filter == NULL) { + return NT_STATUS_NO_MEMORY; } ret = gendb_search(sam, mem_ctx, basedn, msgs, attrs, "%s", filter); -- Samba Shared Repository