summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2018-10-26 13:38:02 +1300
committerKarolin Seeger <kseeger@samba.org>2018-12-04 13:55:09 +0100
commit517df6d3da3ee988d1da96cbba20cbf401ead04e (patch)
treed1c5cf95ed64c80749199b7a3752ddbc5201667b /lib
parenta816ca4004a784a423ef5e4cf195361554f24412 (diff)
downloadsamba-517df6d3da3ee988d1da96cbba20cbf401ead04e.tar.gz
dirsync: Allow arbitrary length cookies
The length of the cookie is proportional to the number of DCs ever in the domain (as it stores the uptodateness vector which has stale invocationID). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit b7a0d3b110697923a31e353905d3b1bd9385ea9b)
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/common/ldb_controls.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c
index a83768a352c..f07f3c535a3 100644
--- a/lib/ldb/common/ldb_controls.c
+++ b/lib/ldb/common/ldb_controls.c
@@ -534,13 +534,20 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_DIRSYNC_NAME) == 0) {
struct ldb_dirsync_control *control;
const char *p;
- char cookie[1024];
+ char *cookie = NULL;
int crit, max_attrs, ret;
uint32_t flags;
- cookie[0] = '\0';
+ cookie = talloc_zero_array(ctrl, char,
+ strlen(control_strings) + 1);
+ if (cookie == NULL) {
+ ldb_oom(ldb);
+ talloc_free(ctrl);
+ return NULL;
+ }
+
p = &(control_strings[sizeof(LDB_CONTROL_DIRSYNC_NAME)]);
- ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie);
+ ret = sscanf(p, "%d:%u:%d:%[^$]", &crit, &flags, &max_attrs, cookie);
if ((ret < 3) || (crit < 0) || (crit > 1) || (max_attrs < 0)) {
ldb_set_errstring(ldb,
@@ -582,17 +589,25 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
control->cookie_len = 0;
}
ctrl->data = control;
+ TALLOC_FREE(cookie);
return ctrl;
}
if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_DIRSYNC_EX_NAME) == 0) {
struct ldb_dirsync_control *control;
const char *p;
- char cookie[1024];
+ char *cookie = NULL;
int crit, max_attrs, ret;
uint32_t flags;
- cookie[0] = '\0';
+ cookie = talloc_zero_array(ctrl, char,
+ strlen(control_strings) + 1);
+ if (cookie == NULL) {
+ ldb_oom(ldb);
+ talloc_free(ctrl);
+ return NULL;
+ }
+
p = &(control_strings[sizeof(LDB_CONTROL_DIRSYNC_EX_NAME)]);
ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie);
@@ -637,6 +652,7 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
control->cookie_len = 0;
}
ctrl->data = control;
+ TALLOC_FREE(cookie);
return ctrl;
}