From: Garming Sam Date: Fri, 26 Oct 2018 00:38:02 +0000 (+1300) Subject: dirsync: Allow arbitrary length cookies X-Git-Tag: tdb-1.3.17~726 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=b7a0d3b110697923a31e353905d3b1bd9385ea9b;hp=8b47443b871c8cfcae60f4d098ff27e561ee6cd4;ds=sidebyside 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 Reviewed-by: Andrew Bartlett --- 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; }