The branch, master has been updated
       via  864f3929456 vfs: Simplify DBGs
       via  dd97a210d40 lib: Remove unused next_token()
       via  1362db6f07f torture4: Test next_token_talloc() instead of 
next_token()
       via  762cd4f759f nsswitch: Remove next_token() from torture4
       via  ae5cda81aff nsswitch: Remove next_token() from wbinfo
       via  d83d270cfad smbd: Remove unused recursive_rmdir()
       via  d7879ef848a vfs: Rewrite vfs_streams_depot
       via  b1748dcc0ad vfs: Slightly simplify streams_depot_fstreaminfo()
       via  c3687ed9390 smbd: Make recursive_rmdir_fsp() public
       via  7240a7483d3 vfs: We expect sane callers of SMB_VFS_RENAMEAT
       via  0164041e019 libsmb: Save lines with a direct variable initialization
       via  3f0d96bc8f8 libsmb: Simplify smbXcli_req_unset_pending()
      from  e3830f2fe4d smbclient3: Replacing Echos in the cli status check 
with TCP status check.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 864f392945615411276b386465a4216315dd0b8c
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 26 13:20:36 2025 +0100

    vfs: Simplify DBGs
    
    Avoid casts: We have PRIu64, size_t is printed with %zu. Only off_t
    must be cast to intmax_t, but for that we should not need a macro.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Wed Mar  5 18:42:03 UTC 2025 on atb-devel-224

commit dd97a210d40f9f47509ee2f9d64dba52c5fe84ea
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 19 07:25:05 2025 +0100

    lib: Remove unused next_token()
    
    Replaced by next_token_talloc()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 1362db6f07f6000997a4e2957707c7435a52a351
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 19 07:22:43 2025 +0100

    torture4: Test next_token_talloc() instead of next_token()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 762cd4f759fa40a23d82480f14b0dbce54c50159
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 19 07:14:22 2025 +0100

    nsswitch: Remove next_token() from torture4
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit ae5cda81aff610b1ef7d48c7054853761bfcfe8d
Author: Volker Lendecke <[email protected]>
Date:   Tue Feb 18 16:17:03 2025 +0100

    nsswitch: Remove next_token() from wbinfo
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d83d270cfad5f36559973a0f1ae32a01748791f3
Author: Volker Lendecke <[email protected]>
Date:   Fri Jan 24 11:26:32 2025 +0100

    smbd: Remove unused recursive_rmdir()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d7879ef848ababcfdb23f1cdfcce0044e438d2ba
Author: Volker Lendecke <[email protected]>
Date:   Fri Jan 3 15:24:01 2025 +0100

    vfs: Rewrite vfs_streams_depot
    
    This started when I found vfs_streams_depot() is the last user of
    recursive_rmdir() and ended as a pretty complete rewrite. Why? This
    new version does not call the path-based NEXT_[L]STAT routines
    anymore, it only uses FSTATAT. This is one tiny step towards getting
    rid of the path-based calls we still have that implicitly depend on
    the current working directory. In some distant future I want to get
    rid of our chdir() calls and do everything relative to a O_PATH handle
    that we opened on the share root when connecting to a share.
    
    This patch removes a few lines, and I don't see a reasonable way to do
    this in micro-steps. Structurally it should be simple though:
    Everything works off streams_depot_rootdir_pathref(), which gives a
    pathref fsp to the ".streams" directory, stream_dir_pathref() turns
    this into a pathref of the actual per-file subdirectory.
    
    We also have to remove the special handling of absolute paths in
    vfs_shadow_copy2, streams_depot does not send absolute paths anymore.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit b1748dcc0add1e7455bb32490dcfb313dc82d491
Author: Volker Lendecke <[email protected]>
Date:   Fri Jan 24 11:21:32 2025 +0100

    vfs: Slightly simplify streams_depot_fstreaminfo()
    
    Use metadata_fsp()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit c3687ed9390bbd452a3d9a004f4bc196549f7d22
Author: Volker Lendecke <[email protected]>
Date:   Thu Jan 2 14:49:30 2025 +0100

    smbd: Make recursive_rmdir_fsp() public
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 7240a7483d35d907eb4753874ca07e9e6132f762
Author: Volker Lendecke <[email protected]>
Date:   Fri Jan 17 13:15:26 2025 +0100

    vfs: We expect sane callers of SMB_VFS_RENAMEAT
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 0164041e0192dde7a8a2e4147d72520c7ffb6f52
Author: Volker Lendecke <[email protected]>
Date:   Mon Feb 10 09:54:52 2025 +0100

    libsmb: Save lines with a direct variable initialization
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 3f0d96bc8f8613fa2659f5c255dd23eb7f4f9f4a
Author: Volker Lendecke <[email protected]>
Date:   Mon Feb 10 11:08:06 2025 +0100

    libsmb: Simplify smbXcli_req_unset_pending()
    
    We have ARRAY_DEL_ELEMENT() for this
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/charset/charset.h             |    1 -
 lib/util/charset/tests/charset.c       |   86 +-
 lib/util/util_str.c                    |   54 +-
 libcli/smb/smbXcli_base.c              |   17 +-
 nsswitch/wbinfo.c                      |  108 ++-
 source3/include/proto.h                |    1 -
 source3/modules/vfs_ceph_new.c         |   60 +-
 source3/modules/vfs_shadow_copy2.c     |   22 +-
 source3/modules/vfs_streams_depot.c    | 1617 +++++++++++++++-----------------
 source3/smbd/close.c                   |   19 +-
 source3/smbd/proto.h                   |    4 +-
 source4/torture/winbind/struct_based.c |   17 +-
 12 files changed, 943 insertions(+), 1063 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 4316c1b2c6c..ab91c0abd43 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -165,7 +165,6 @@ int strncasecmp_ldb(const char *s1,
 int strncasecmp_m(const char *s1, const char *s2, size_t n);
 int strncasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
                         const char *s1, const char *s2, size_t n);
-bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize);
 int strcasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
                        const char *s1, const char *s2);
 int strcasecmp_m(const char *s1, const char *s2);
diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c
index 46f89cb9ef4..e1abd71dfbd 100644
--- a/lib/util/charset/tests/charset.c
+++ b/lib/util/charset/tests/charset.c
@@ -182,88 +182,130 @@ static bool test_strncasecmp_m(struct torture_context 
*tctx)
 
 static bool test_next_token_null(struct torture_context *tctx)
 {
-       char buf[20];
-       torture_assert(tctx, !next_token(NULL, buf, " ", 20), "null ptr works");
+       char *buf = NULL;
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, NULL, &buf, " "),
+                      "null ptr works");
        return true;
 }
 
 static bool test_next_token(struct torture_context *tctx)
 {
        const char *teststr = "foo bar bla";
-       char buf[20];
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       char *buf = NULL;
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "foo", "token matches");
        torture_assert_str_equal(tctx, teststr, "bar bla", "ptr modified 
correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "bar", "token matches");
        torture_assert_str_equal(tctx, teststr, "bla", "ptr modified 
correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "bla", "token matches");
        torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, !next_token(&teststr, buf, " ", 20), "finding 
token doesn't work");
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token doesn't work");
        return true;
 }
 
 static bool test_next_token_implicit_sep(struct torture_context *tctx)
 {
        const char *teststr = "foo\tbar\n bla";
-       char buf[20];
-       torture_assert(tctx, next_token(&teststr, buf, NULL, 20), "finding 
token works");
+       char *buf = NULL;
+
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, NULL),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "foo", "token matches");
        torture_assert_str_equal(tctx, teststr, "bar\n bla", "ptr modified 
correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, next_token(&teststr, buf, NULL, 20), "finding 
token works");
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, NULL),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "bar", "token matches");
        torture_assert_str_equal(tctx, teststr, " bla", "ptr modified 
correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, next_token(&teststr, buf, NULL, 20), "finding 
token works");
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, NULL),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "bla", "token matches");
        torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, !next_token(&teststr, buf, NULL, 20), "finding 
token doesn't work");
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, &teststr, &buf, NULL),
+                      "finding token doesn't work");
        return true;
 }
 
 static bool test_next_token_seps(struct torture_context *tctx)
 {
        const char *teststr = ",foo bla";
-       char buf[20];
-       torture_assert(tctx, next_token(&teststr, buf, ",", 20), "finding token 
works");
+       char *buf = NULL;
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, ","),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "foo bla", "token matches");
        torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, !next_token(&teststr, buf, ",", 20), "finding 
token doesn't work");
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, &teststr, &buf, ","),
+                      "finding token doesn't work");
        return true;
 }
 
 static bool test_next_token_quotes(struct torture_context *tctx)
 {
        const char *teststr = "\"foo bar\" bla";
-       char buf[20];
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       char *buf = NULL;
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "foo bar", "token matches");
        torture_assert_str_equal(tctx, teststr, "bla", "ptr modified 
correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "bla", "token matches");
        torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");
+       TALLOC_FREE(buf);
 
-       torture_assert(tctx, !next_token(&teststr, buf, " ", 20), "finding 
token doesn't work");
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token doesn't work");
        return true;
 }
 
 static bool test_next_token_quote_wrong(struct torture_context *tctx)
 {
        const char *teststr = "\"foo bar bla";
-       char buf[20];
-       torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token 
works");
+       char *buf = NULL;
+       torture_assert(tctx,
+                      next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token works");
        torture_assert_str_equal(tctx, buf, "foo bar bla", "token matches");
        torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");
 
-       torture_assert(tctx, !next_token(&teststr, buf, " ", 20), "finding 
token doesn't work");
+       torture_assert(tctx,
+                      !next_token_talloc(tctx, &teststr, &buf, " "),
+                      "finding token doesn't work");
        return true;
 }
 
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index 7c1d15dbeb0..19acff4a983 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -141,6 +141,14 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2)
  * @brief String utilities.
  **/
 
+/**
+ * Get the next token from a string, return False if none found.
+ * Handles double-quotes.
+ *
+ * Based on a routine by [email protected].
+ * Extensively modified by [email protected]
+ **/
+
 static bool next_token_internal_talloc(TALLOC_CTX *ctx,
                                const char **ptr,
                                 char **pp_buff,
@@ -236,52 +244,6 @@ bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
        return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
 }
 
-/**
- * Get the next token from a string, return False if none found.
- * Handles double-quotes.
- *
- * Based on a routine by [email protected].
- * Extensively modified by [email protected]
- **/
-_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t 
bufsize)
-{
-       const char *s;
-       bool quoted;
-       size_t len=1;
-
-       if (!ptr)
-               return false;
-
-       s = *ptr;
-
-       /* default to simple separators */
-       if (!sep)
-               sep = " \t\n\r";
-
-       /* find the first non sep char */
-       while (*s && strchr_m(sep,*s))
-               s++;
-
-       /* nothing left? */
-       if (!*s)
-               return false;
-
-       /* copy over the token */
-       for (quoted = false; len < bufsize && *s && (quoted || 
!strchr_m(sep,*s)); s++) {
-               if (*s == '\"') {
-                       quoted = !quoted;
-               } else {
-                       len++;
-                       *buff++ = *s;
-               }
-       }
-
-       *ptr = (*s) ? s+1 : s;
-       *buff = 0;
-
-       return true;
-}
-
 /**
  Set a boolean variable from the text value stored in the passed string.
  Returns true in success, false if the passed string does not correctly
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 7f275b59991..f61015f84c1 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -1063,12 +1063,7 @@ void smbXcli_req_unset_pending(struct tevent_req *req)
                return;
        }
 
-       /*
-        * Remove ourselves from the conn->pending array
-        */
-       for (; i < (num_pending - 1); i++) {
-               conn->pending[i] = conn->pending[i+1];
-       }
+       ARRAY_DEL_ELEMENT(conn->pending, i, num_pending);
 
        /*
         * No NULL check here, we're shrinking by sizeof(void *), and
@@ -1154,18 +1149,14 @@ bool smbXcli_req_set_pending(struct tevent_req *req)
        struct smbXcli_req_state *state =
                tevent_req_data(req,
                struct smbXcli_req_state);
-       struct smbXcli_conn *conn;
-       struct tevent_req **pending;
-       size_t num_pending;
-
-       conn = state->conn;
+       struct smbXcli_conn *conn = state->conn;
+       struct tevent_req **pending = NULL;
+       size_t num_pending = talloc_array_length(conn->pending);
 
        if (!smbXcli_conn_is_connected(conn)) {
                return false;
        }
 
-       num_pending = talloc_array_length(conn->pending);
-
        pending = talloc_realloc(conn, conn->pending, struct tevent_req *,
                                 num_pending+1);
        if (pending == NULL) {
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index 4d0179edde9..93caa96f66c 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -1031,93 +1031,101 @@ static bool wbinfo_sid_to_gid(const char *sid_str)
 
 static bool wbinfo_sids_to_unix_ids(const char *arg)
 {
-       char sidstr[WBC_SID_STRING_BUFLEN];
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *sidstr = NULL;
        struct wbcDomainSid *sids;
        struct wbcUnixId *unix_ids;
        int i, num_sids;
        const char *p;
        wbcErr wbc_status;
-
+       bool ret = false;
 
        num_sids = 0;
        sids = NULL;
        p = arg;
 
-       while (next_token(&p, sidstr, LIST_SEP, sizeof(sidstr))) {
-               sids = talloc_realloc(talloc_tos(), sids, struct wbcDomainSid,
-                                     num_sids+1);
+       while (next_token_talloc(frame, &p, &sidstr, LIST_SEP)) {
+               sids = talloc_realloc(frame,
+                                     sids,
+                                     struct wbcDomainSid,
+                                     num_sids + 1);
                if (sids == NULL) {
                        d_fprintf(stderr, "talloc failed\n");
-                       return false;
+                       goto fail;
                }
                wbc_status = wbcStringToSid(sidstr, &sids[num_sids]);
                if (!WBC_ERROR_IS_OK(wbc_status)) {
                        d_fprintf(stderr, "wbcSidToString(%s) failed: %s\n",
                                  sidstr, wbcErrorString(wbc_status));
-                       TALLOC_FREE(sids);
-                       return false;
+                       goto fail;
                }
+               TALLOC_FREE(sidstr);
                num_sids += 1;
        }
 
-       unix_ids = talloc_array(talloc_tos(), struct wbcUnixId, num_sids);
+       unix_ids = talloc_array(frame, struct wbcUnixId, num_sids);
        if (unix_ids == NULL) {
-               TALLOC_FREE(sids);
-               return false;
+               goto fail;
        }
 
        wbc_status = wbcSidsToUnixIds(sids, num_sids, unix_ids);
        if (!WBC_ERROR_IS_OK(wbc_status)) {
                d_fprintf(stderr, "wbcSidsToUnixIds failed: %s\n",
                          wbcErrorString(wbc_status));
-               TALLOC_FREE(sids);
-               return false;
+               goto fail;
        }
 
        for (i=0; i<num_sids; i++) {
+               fstring sidbuf;
 
-               wbcSidToStringBuf(&sids[i], sidstr, sizeof(sidstr));
+               wbcSidToStringBuf(&sids[i], sidbuf, sizeof(sidbuf));
 
                switch(unix_ids[i].type) {
                case WBC_ID_TYPE_UID:
-                       d_printf("%s -> uid %d\n", sidstr, unix_ids[i].id.uid);
+                       d_printf("%s -> uid %d\n", sidbuf, unix_ids[i].id.uid);
                        break;
                case WBC_ID_TYPE_GID:
-                       d_printf("%s -> gid %d\n", sidstr, unix_ids[i].id.gid);
+                       d_printf("%s -> gid %d\n", sidbuf, unix_ids[i].id.gid);
                        break;
                case WBC_ID_TYPE_BOTH:
-                       d_printf("%s -> uid/gid %d\n", sidstr, 
unix_ids[i].id.uid);
+                       d_printf("%s -> uid/gid %d\n",
+                                sidbuf,
+                                unix_ids[i].id.uid);
                        break;
                default:
-                       d_printf("%s -> unmapped\n", sidstr);
+                       d_printf("%s -> unmapped\n", sidbuf);
                        break;
                }
        }
 
-       TALLOC_FREE(sids);
-       TALLOC_FREE(unix_ids);
-
-       return true;
+       ret = true;
+fail:
+       TALLOC_FREE(frame);
+       return ret;
 }
 
 static bool wbinfo_xids_to_sids(const char *arg)
 {
-       fstring idstr;
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *idstr = NULL;
        struct wbcUnixId *xids = NULL;
        struct wbcDomainSid *sids;
        wbcErr wbc_status;
        int num_xids = 0;
        const char *p;
        int i;
+       bool ret = false;
 
        p = arg;
 
-       while (next_token(&p, idstr, LIST_SEP, sizeof(idstr))) {
-               xids = talloc_realloc(talloc_tos(), xids, struct wbcUnixId,
-                                     num_xids+1);
+       while (next_token_talloc(frame, &p, &idstr, LIST_SEP)) {
+               xids = talloc_realloc(xids,
+                                     xids,
+                                     struct wbcUnixId,
+                                     num_xids + 1);
                if (xids == NULL) {
                        d_fprintf(stderr, "talloc failed\n");
-                       return false;
+                       goto fail;
                }
 
                switch (idstr[0]) {
@@ -1135,26 +1143,23 @@ static bool wbinfo_xids_to_sids(const char *arg)
                        break;
                default:
                        d_fprintf(stderr, "%s is an invalid id\n", idstr);
-                       TALLOC_FREE(xids);
-                       return false;
+                       goto fail;
                }
+               TALLOC_FREE(idstr);
                num_xids += 1;
        }
 
-       sids = talloc_array(talloc_tos(), struct wbcDomainSid, num_xids);
+       sids = talloc_array(frame, struct wbcDomainSid, num_xids);
        if (sids == NULL) {
                d_fprintf(stderr, "talloc failed\n");
-               TALLOC_FREE(xids);
-               return false;
+               goto fail;
        }
 
        wbc_status = wbcUnixIdsToSids(xids, num_xids, sids);
        if (!WBC_ERROR_IS_OK(wbc_status)) {
                d_fprintf(stderr, "wbcUnixIdsToSids failed: %s\n",
                          wbcErrorString(wbc_status));
-               TALLOC_FREE(sids);
-               TALLOC_FREE(xids);
-               return false;
+               goto fail;
        }
 
        for (i=0; i<num_xids; i++) {
@@ -1169,7 +1174,10 @@ static bool wbinfo_xids_to_sids(const char *arg)
                d_printf("%s\n", str);
        }
 
-       return true;
+       ret = true;
+fail:
+       TALLOC_FREE(frame);
+       return ret;
 }
 
 static bool wbinfo_allocate_uid(void)
@@ -1502,7 +1510,8 @@ done:
 
 static bool wbinfo_lookup_sids(const char *arg)
 {
-       char sidstr[WBC_SID_STRING_BUFLEN];
+       TALLOC_CTX *frame = talloc_stackframe();
+       char *sidstr = NULL;
        struct wbcDomainSid *sids;
        struct wbcDomainInfo *domains;
        struct wbcTranslatedName *names;
@@ -1510,26 +1519,28 @@ static bool wbinfo_lookup_sids(const char *arg)
        int i, num_sids;
        const char *p;
        wbcErr wbc_status;
-
+       bool ret;
 
        num_sids = 0;
        sids = NULL;
        p = arg;
 
-       while (next_token(&p, sidstr, LIST_SEP, sizeof(sidstr))) {
-               sids = talloc_realloc(talloc_tos(), sids, struct wbcDomainSid,
-                                     num_sids+1);
+       while (next_token_talloc(frame, &p, &sidstr, LIST_SEP)) {
+               sids = talloc_realloc(frame,
+                                     sids,
+                                     struct wbcDomainSid,
+                                     num_sids + 1);
                if (sids == NULL) {
                        d_fprintf(stderr, "talloc failed\n");
-                       return false;
+                       goto fail;
                }
                wbc_status = wbcStringToSid(sidstr, &sids[num_sids]);
                if (!WBC_ERROR_IS_OK(wbc_status)) {
                        d_fprintf(stderr, "wbcSidToString(%s) failed: %s\n",
                                  sidstr, wbcErrorString(wbc_status));
-                       TALLOC_FREE(sids);
-                       return false;
+                       goto fail;
                }


-- 
Samba Shared Repository

Reply via email to