The branch, master has been updated
       via  aab2f39 autobuild: Return the last 50 log lines
       via  5e4f39a ldb_controls: avoid unnecessary unchecked talloc_asprintf()s
       via  bd6a022 ldb controls: allow paged_search to use a cookie
       via  7bd0661 ldb client controls: don't ignore failed memdup
       via  66c5082 dsdb python tests: fix several usage strings
       via  52975b0 dsdb sort test: avoid exception with fewer elements
       via  0edb3da ldb sort tests: point out a known fails against Windows
       via  578643f ldb controls: don't ignore memory allocation failure
       via  79c58c2 Implement Virtual List View (VLV)
       via  cd594a3 sort: enable custom behaviour on critical control
       via  a3ffac3 ndrdump: add quiet flag
       via  c20e7b8 ndr: inline search for ndr_token_peek()
       via  59d530c ndr: Use ndr_steal to avoid long lists
       via  7261433 librpc ndr: add ndr_pull_steal_switch_value()
       via  9af628a ndr: avoid unnecessary searches of token list
      from  bac35a1 nsswitch: winbind_nss_solaris.c: Remove unused macro 
containing strcpy.

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


- Log -----------------------------------------------------------------
commit aab2f39bb7ff330fbb01da4021c096e69a429d2e
Author: Garming Sam <[email protected]>
Date:   Mon Mar 14 14:18:54 2016 +1300

    autobuild: Return the last 50 log lines
    
    This means that you don't have to deal with tars for quickly determining
    the cause of a failure.
    
    Signed-off-by: Garming Sam <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    
    Autobuild-User(master): Andrew Bartlett <[email protected]>
    Autobuild-Date(master): Tue Mar 22 11:39:38 CET 2016 on sn-devel-144

commit 5e4f39ad60f4cf0bd3a2f793e4572b09163a4ce1
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 22 13:42:12 2016 +1300

    ldb_controls: avoid unnecessary unchecked talloc_asprintf()s
    
    The error paths when a control doesn't parse involved a lot of
    talloc_asprintf()s and talloc_asprintf_append()s but almost no actual
    printf formatting. The return values were not checked. This replaces
    them with constant strings.
    
    The one case that did use formatting looked like this:
    
     "invalid %s control syntax\n",  LDB_CONTROL_DIRSYNC_EX_NAME
    
    and that has been replaced with
    
      "invalid dirsync_ex control syntax\n"
    
    in line with the way it is done elsewhere.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit bd6a0220f47a045590641da78e133ca9c06a6a97
Author: Douglas Bagnall <[email protected]>
Date:   Wed Mar 16 12:56:09 2016 +1300

    ldb controls: allow paged_search to use a cookie
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 7bd06613da4efa63a2c97260e018878aa50e15a5
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 22 13:32:12 2016 +1300

    ldb client controls: don't ignore failed memdup
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 66c5082952b017f46248966488e55f5f68fecef7
Author: Douglas Bagnall <[email protected]>
Date:   Fri Mar 11 15:17:43 2016 +1300

    dsdb python tests: fix several usage strings
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 52975b046c1c40721bb68dca8ea9d4a5c19da099
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 22 10:25:27 2016 +1300

    dsdb sort test: avoid exception with fewer elements
    
    The FIENDISH_TESTS list has 33 members, and when the number of
    elements being tested is less than that (because you run the script
    with, say, --elements=20) some will have a zero count. A recent fix
    for Python 2.6 didn't take these possible zeros into account.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 0edb3da532e770980bbbf87b8afbd4f463773ed2
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 15 12:51:18 2016 +1300

    ldb sort tests: point out a known fails against Windows
    
    It seems that Windows 2012R2 has issues ordering attributes with the
    "generalized time" syntax (2.5.5.11), and that these show up in our
    tests when the number of elements exceeds 27. As far as I can tell
    there is no logic to the results after that point.
    
    To avoid failures, use the --elements option, like this:
    
    python source4/dsdb/tests/python/sort.py --elements=25
    
    Against Samba this makes no difference because we don't fail.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 578643fb3613c6c59e31d848a032fea2fd514dd5
Author: Douglas Bagnall <[email protected]>
Date:   Fri Mar 11 10:26:10 2016 +1300

    ldb controls: don't ignore memory allocation failure
    
    Thanks to Jeremy Allison for noticing this.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 79c58c2543790134ef8deb5307ec4b4ae069ea61
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 8 14:28:33 2016 +1300

    Implement Virtual List View (VLV)
    
    VLV is a more sophisticated version of a paged searches that allows
    you to ask for arbitrary windows in a previously performed sorted
    search. If clients use VLV correctly the original search will not be
    repeated.
    
    Pair-programmed-with: Garming Sam <[email protected]>
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Signed-off-by: Garming Sam <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit cd594a3cb384e8628d8f8bd62c64e1531fc68778
Author: Garming Sam <[email protected]>
Date:   Thu Mar 10 15:25:44 2016 +1300

    sort: enable custom behaviour on critical control
    
    The sort module should simply return unsorted results when a sort is
    unsupported but not critical. A similar custom behaviour should be
    expected with VLV pagination when it is enabled.
    
    Signed-off-by: Garming Sam <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit a3ffac33f27b7b0cd6875eab0ae93b6f9e9a3015
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 1 14:13:18 2016 +1300

    ndrdump: add quiet flag
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Signed-off-by: Garming Sam <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>

commit c20e7b8c011d193da5e03c8bda0b0aaaf0c5a906
Author: Douglas Bagnall <[email protected]>
Date:   Fri Feb 26 16:58:09 2016 +1300

    ndr: inline search for ndr_token_peek()
    
    This is often a hot path, particularly with complex structures like
    nt-acls.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 59d530c0b692dae41ea271bfdb473f212615041b
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 1 14:18:52 2016 +1300

    ndr: Use ndr_steal to avoid long lists
    
    When pulling complex structures like nt-acls, a long list of tokens may
    be produced. By removing tokens along the way with ndr_token_steal,
    future calls to retrieve from the token list are not as expensive.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 7261433fe19fde19353ee42c17607cf04af47a1c
Author: Douglas Bagnall <[email protected]>
Date:   Tue Mar 1 12:26:33 2016 +1300

    librpc ndr: add ndr_pull_steal_switch_value()
    
    Switch values currently only have a peek variant, instead of a retrieve
    variant for getting their values. This can create performance issues
    with complex structures as the token list simply grows longer.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

commit 9af628a488d2b628e6c33917be7030602eeb5fde
Author: Douglas Bagnall <[email protected]>
Date:   Fri Feb 26 17:01:37 2016 +1300

    ndr: avoid unnecessary searches of token list
    
    When pulling complex structures like nt-acls, a long list of tokens
    may be produced. This change means the token list won't be walked in the
    buffers case if the switch value is not needed.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    Reviewed-by: Garming Sam <[email protected]>

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

Summary of changes:
 lib/ldb/common/ldb_controls.c                      | 277 +++----
 lib/ldb/modules/sort.c                             |   2 +
 librpc/ABI/{ndr-0.0.5.sigs => ndr-0.0.6.sigs}      |   1 +
 librpc/ndr/libndr.h                                |   1 +
 librpc/ndr/ndr.c                                   |  28 +-
 librpc/tools/ndrdump.c                             |  19 +-
 librpc/wscript_build                               |   2 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm           |  57 +-
 script/autobuild.py                                |  13 +-
 source4/dsdb/samdb/ldb_modules/rootdse.c           |  17 +-
 source4/dsdb/samdb/ldb_modules/samba_dsdb.c        |   1 +
 source4/dsdb/samdb/ldb_modules/vlv_pagination.c    | 766 ++++++++++++++++++++
 .../dsdb/samdb/ldb_modules/wscript_build_server    |   9 +
 source4/dsdb/tests/python/ldap_syntaxes.py         |   2 +-
 source4/dsdb/tests/python/password_lockout.py      |   2 +-
 source4/dsdb/tests/python/sites.py                 |   2 +-
 source4/dsdb/tests/python/sort.py                  |  20 +-
 source4/dsdb/tests/python/token_group.py           |   2 +-
 source4/dsdb/tests/python/user_account_control.py  |   2 +-
 source4/dsdb/tests/python/vlv.py                   | 802 +++++++++++++++++++++
 source4/selftest/tests.py                          |   1 +
 21 files changed, 1852 insertions(+), 174 deletions(-)
 copy librpc/ABI/{ndr-0.0.5.sigs => ndr-0.0.6.sigs} (99%)
 create mode 100644 source4/dsdb/samdb/ldb_modules/vlv_pagination.c
 create mode 100644 source4/dsdb/tests/python/vlv.py


Changeset truncated at 500 lines:

diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c
index 0fdd13a..a83768a 100644
--- a/lib/ldb/common/ldb_controls.c
+++ b/lib/ldb/common/ldb_controls.c
@@ -315,6 +315,9 @@ char *ldb_control_to_string(TALLOC_CTX *mem_ctx, const 
struct ldb_control *contr
                cookie = ldb_base64_encode(mem_ctx,
                                           (char *)rep_control->contextId,
                                           rep_control->ctxid_len);
+               if (cookie == NULL) {
+                       return NULL;
+               }
 
                res = talloc_asprintf(mem_ctx, "%s:%d:%d:%d:%d:%s",
                                                LDB_CONTROL_VLV_RESP_NAME,
@@ -443,7 +446,6 @@ char *ldb_control_to_string(TALLOC_CTX *mem_ctx, const 
struct ldb_control *contr
 struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, 
TALLOC_CTX *mem_ctx, const char *control_strings)
 {
        struct ldb_control *ctrl;
-       char *error_string = NULL;
 
        if (!(ctrl = talloc(mem_ctx, struct ldb_control))) {
                ldb_oom(ldb);
@@ -478,12 +480,11 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                }
 
                if ((ret < 4) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid VLV 
control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):bc(n):ac(n):"
-                                                             
"{os(n):cc(n)|>=val(s)|base64>=val(o)}[:ctxid(o)]\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number, s = string, o = b64 binary blob");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid VLV control syntax\n"
+                                         " syntax: crit(b):bc(n):ac(n):"
+                                         
"{os(n):cc(n)|>=val(s)|base64>=val(o)}[:ctxid(o)]\n"
+                                         "   note: b = boolean, n = number, s 
= string, o = b64 binary blob");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -517,6 +518,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                        control->ctxid_len = len;
                        control->contextId = talloc_memdup(control, ctxid,
                                                           control->ctxid_len);
+                       if (control->contextId == NULL) {
+                               ldb_oom(ldb);
+                               return NULL;
+                       }
                } else {
                        control->ctxid_len = 0;
                        control->contextId = NULL;
@@ -532,17 +537,16 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                char cookie[1024];
                int crit, max_attrs, ret;
                uint32_t flags;
-               
+
                cookie[0] = '\0';
                p = &(control_strings[sizeof(LDB_CONTROL_DIRSYNC_NAME)]);
                ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, 
&max_attrs, cookie);
 
                if ((ret < 3) || (crit < 0) || (crit > 1) || (max_attrs < 0)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
dirsync control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number, o = b64 binary blob");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid dirsync control syntax\n"
+                                         " syntax: 
crit(b):flags(n):max_attrs(n)[:cookie(o)]\n"
+                                         "   note: b = boolean, n = number, o 
= b64 binary blob");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -569,6 +573,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                        }
                        control->cookie_len = len;
                        control->cookie = (char *)talloc_memdup(control, 
cookie, control->cookie_len);
+                       if (control->cookie == NULL) {
+                               ldb_oom(ldb);
+                               return NULL;
+                       }
                } else {
                        control->cookie = NULL;
                        control->cookie_len = 0;
@@ -589,12 +597,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, 
&max_attrs, cookie);
 
                if ((ret < 3) || (crit < 0) || (crit > 1) || (max_attrs < 0)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid %s 
control syntax\n",
-                                                      
LDB_CONTROL_DIRSYNC_EX_NAME);
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number, o = b64 binary blob");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid dirsync_ex control syntax\n"
+                                         " syntax: 
crit(b):flags(n):max_attrs(n)[:cookie(o)]\n"
+                                         "   note: b = boolean, n = number, o 
= b64 binary blob");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -622,6 +628,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                        }
                        control->cookie_len = len;
                        control->cookie = (char *)talloc_memdup(control, 
cookie, control->cookie_len);
+                       if (control->cookie == NULL) {
+                               ldb_oom(ldb);
+                               return NULL;
+                       }
                } else {
                        control->cookie = NULL;
                        control->cookie_len = 0;
@@ -641,11 +651,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_ASQ_NAME)]);
                ret = sscanf(p, "%d:%255[^$]", &crit, attr);
                if ((ret != 2) || (crit < 0) || (crit > 1) || (attr[0] == 
'\0')) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid asq 
control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):attr(s)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, s = string");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid asq control syntax\n"
+                                         " syntax: crit(b):attr(s)\n"
+                                         "   note: b = boolean, s = string");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -671,14 +680,13 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                if ((ret != 2) || (crit < 0) || (crit > 1) || (type < 0) || 
(type > 1)) {
                        ret = sscanf(p, "%d", &crit);
                        if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                               error_string = talloc_asprintf(mem_ctx, 
"invalid extended_dn control syntax\n");
-                               error_string = 
talloc_asprintf_append(error_string, " syntax: crit(b)[:type(i)]\n");
-                               error_string = 
talloc_asprintf_append(error_string, "   note: b = boolean\n");
-                               error_string = 
talloc_asprintf_append(error_string, "         i = integer\n");
-                               error_string = 
talloc_asprintf_append(error_string, "   valid values are: 0 - hexadecimal 
representation\n");
-                               error_string = 
talloc_asprintf_append(error_string, "                     1 - normal string 
representation");
-                               ldb_set_errstring(ldb, error_string);
-                               talloc_free(error_string);
+                               ldb_set_errstring(ldb,
+                                                 "invalid extended_dn control 
syntax\n"
+                                                 " syntax: crit(b)[:type(i)]\n"
+                                                 "   note: b = boolean\n"
+                                                 "         i = integer\n"
+                                                 "   valid values are: 0 - 
hexadecimal representation\n"
+                                                 "                     1 - 
normal string representation");
                                talloc_free(ctrl);
                                return NULL;
                        }
@@ -704,11 +712,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_SD_FLAGS_NAME)]);
                ret = sscanf(p, "%d:%u", &crit, &secinfo_flags);
                if ((ret != 2) || (crit < 0) || (crit > 1) || (secinfo_flags > 
0xF)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
sd_flags control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):secinfo_flags(n)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid sd_flags control syntax\n"
+                                         " syntax: crit(b):secinfo_flags(n)\n"
+                                         "   note: b = boolean, n = number");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -731,11 +738,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_SEARCH_OPTIONS_NAME)]);
                ret = sscanf(p, "%d:%u", &crit, &search_options);
                if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options > 
0xF)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
search_options control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):search_options(n)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid search_options control 
syntax\n"
+                                         " syntax: crit(b):search_options(n)\n"
+                                         "   note: b = boolean, n = number");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -756,11 +762,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = 
&(control_strings[sizeof(LDB_CONTROL_BYPASS_OPERATIONAL_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
bypassopreational control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid bypassopreational control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -779,11 +784,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_RELAX_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid relax 
control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid relax control syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -802,11 +806,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_RECALCULATE_SD_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
recalculate_sd control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid recalculate_sd control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -825,11 +828,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_DOMAIN_SCOPE_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
domain_scope control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid domain_scope control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -844,16 +846,18 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
        if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_PAGED_RESULTS_NAME) == 
0) {
                struct ldb_paged_control *control;
                const char *p;
+               char cookie[1024];
                int crit, size, ret;
-               
+
+               cookie[0] = '\0';
                p = &(control_strings[sizeof(LDB_CONTROL_PAGED_RESULTS_NAME)]);
-               ret = sscanf(p, "%d:%d", &crit, &size);
-               if ((ret != 2) || (crit < 0) || (crit > 1) || (size < 0)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
paged_results control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):size(n)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, n = number");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+               ret = sscanf(p, "%d:%d:%1023[^$]", &crit, &size, cookie);
+               if ((ret < 2) || (ret > 3) || (crit < 0) || (crit > 1) ||
+                   (size < 0)) {
+                       ldb_set_errstring(ldb,
+                               "invalid paged_results control syntax\n"
+                               " syntax: crit(b):size(n)[:cookie(base64)]\n"
+                               "   note: b = boolean, n = number");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -862,8 +866,25 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                ctrl->critical = crit;
                control = talloc(ctrl, struct ldb_paged_control);
                control->size = size;
-               control->cookie = NULL;
-               control->cookie_len = 0;
+               if (cookie[0] != '\0') {
+                       int len = ldb_base64_decode(cookie);
+                       if (len < 0) {
+                               ldb_set_errstring(ldb,
+                                                 "invalid paged_results cookie"
+                                                 " (probably too long)\n");
+                               talloc_free(ctrl);
+                               return NULL;
+                       }
+                       control->cookie_len = len;
+                       control->cookie = talloc_memdup(control, cookie, 
control->cookie_len);
+                       if (control->cookie == NULL) {
+                               ldb_oom(ldb);
+                               return NULL;
+                       }
+               } else {
+                       control->cookie = NULL;
+                       control->cookie_len = 0;
+               }
                ctrl->data = control;
 
                return ctrl;
@@ -881,11 +902,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_SERVER_SORT_NAME)]);
                ret = sscanf(p, "%d:%d:%255[^:]:%127[^:]", &crit, &rev, attr, 
rule);
                if ((ret < 3) || (crit < 0) || (crit > 1) || (rev < 0 ) || (rev 
> 1) ||attr[0] == '\0') {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
server_sort control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b):rev(b):attr(s)[:rule(s)]\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, s = string");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid server_sort control syntax\n"
+                                         " syntax: 
crit(b):rev(b):attr(s)[:rule(s)]\n"
+                                         "   note: b = boolean, s = string");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -912,11 +932,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_NOTIFICATION_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
notification control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid notification control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -935,11 +954,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_TREE_DELETE_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
tree_delete control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid tree_delete control syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -958,11 +976,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_SHOW_DELETED_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
show_deleted control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid show_deleted control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -981,11 +998,10 @@ struct ldb_control *ldb_parse_control_from_string(struct 
ldb_context *ldb, TALLO
                p = 
&(control_strings[sizeof(LDB_CONTROL_SHOW_DEACTIVATED_LINK_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
show_deactivated_link control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid show_deactivated_link 
control syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1004,11 +1020,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_SHOW_RECYCLED_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
show_recycled control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid show_recycled control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1027,11 +1042,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                p = 
&(control_strings[sizeof(LDB_CONTROL_PERMISSIVE_MODIFY_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
permissive_modify control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid permissive_modify control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1050,11 +1064,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                p = 
&(control_strings[sizeof(LDB_CONTROL_REVEAL_INTERNALS_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
reveal_internals control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid reveal_internals control 
syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1076,11 +1089,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                ret = sscanf(p, "%255[^:]:%d", oid, &crit);
 
                if ((ret != 2) || strlen(oid) == 0 || (crit < 0) || (crit > 1)) 
{
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
local_oid control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: oid(s):crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean, s = string");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid local_oid control syntax\n"
+                                         " syntax: oid(s):crit(b)\n"
+                                         "   note: b = boolean, s = string");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1104,11 +1116,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_RODC_DCPROMO_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
rodc_join control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid rodc_join control syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1127,11 +1138,10 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                p = &(control_strings[sizeof(LDB_CONTROL_PROVISION_NAME)]);
                ret = sscanf(p, "%d", &crit);
                if ((ret != 1) || (crit < 0) || (crit > 1)) {
-                       error_string = talloc_asprintf(mem_ctx, "invalid 
provision control syntax\n");
-                       error_string = talloc_asprintf_append(error_string, " 
syntax: crit(b)\n");
-                       error_string = talloc_asprintf_append(error_string, "   
note: b = boolean");
-                       ldb_set_errstring(ldb, error_string);
-                       talloc_free(error_string);
+                       ldb_set_errstring(ldb,
+                                         "invalid provision control syntax\n"
+                                         " syntax: crit(b)\n"
+                                         "   note: b = boolean");
                        talloc_free(ctrl);
                        return NULL;
                }
@@ -1155,13 +1165,12 @@ struct ldb_control 
*ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
                if ((ret != 3) || (crit < 0) || (crit > 1)) {
                        ret = sscanf(p, "%d:%d", &crit, &flags);
                        if ((ret != 2) || (crit < 0) || (crit > 1)) {
-                               error_string = talloc_asprintf(mem_ctx, 
"invalid verify_name control syntax\n");
-                               error_string = 
talloc_asprintf_append(error_string, " syntax: crit(b):flags(i)[:gc(s)]\n");
-                               error_string = 
talloc_asprintf_append(error_string, "   note: b = boolean");
-                               error_string = 
talloc_asprintf_append(error_string, "   note: i = integer");
-                               error_string = 
talloc_asprintf_append(error_string, "   note: s = string");
-                               ldb_set_errstring(ldb, error_string);
-                               talloc_free(error_string);
+                               ldb_set_errstring(ldb,
+                                                 "invalid verify_name control 
syntax\n"
+                                                 " syntax: 
crit(b):flags(i)[:gc(s)]\n"
+                                                 "   note: b = boolean"
+                                                 "   note: i = integer"
+                                                 "   note: s = string");
                                talloc_free(ctrl);
                                return NULL;
                        }
diff --git a/lib/ldb/modules/sort.c b/lib/ldb/modules/sort.c
index 19cf60b..cb6f8df 100644


-- 
Samba Shared Repository

Reply via email to