s4-dsdb: don't use a non-constant format string for a printf format
authorAndrew Tridgell <tridge@samba.org>
Sat, 19 Dec 2009 09:58:00 +0000 (20:58 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 21 Dec 2009 12:41:06 +0000 (23:41 +1100)
source4/dsdb/samdb/ldb_modules/util.c

index 8503584ea6e13f6dabcce3815118a45c686e808c..b0ccd0341ceae0598db76436f2236cc0ecab99d9 100644 (file)
@@ -232,22 +232,15 @@ int dsdb_module_dn_by_guid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
 {
        struct ldb_result *res;
        const char *attrs[] = { NULL };
-       char *expression;
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
        int ret;
 
-       expression = talloc_asprintf(tmp_ctx, "objectGUID=%s", GUID_string(tmp_ctx, guid));
-       if (!expression) {
-               ldb_module_oom(module);
-               return LDB_ERR_OPERATIONS_ERROR;
-       }
-
        ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
                                 attrs,
                                 DSDB_SEARCH_SHOW_DELETED |
                                 DSDB_SEARCH_SEARCH_ALL_PARTITIONS |
                                 DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
-                                expression);
+                                "objectGUID=%s", GUID_string(tmp_ctx, guid));
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                return ret;
@@ -257,8 +250,8 @@ int dsdb_module_dn_by_guid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
                return LDB_ERR_NO_SUCH_OBJECT;
        }
        if (res->count != 1) {
-               ldb_asprintf_errstring(ldb_module_get_ctx(module), "More than one object found matching %s\n",
-                                      expression);
+               ldb_asprintf_errstring(ldb_module_get_ctx(module), "More than one object found matching objectGUID %s\n",
+                                      GUID_string(tmp_ctx, guid));
                talloc_free(tmp_ctx);
                return LDB_ERR_OPERATIONS_ERROR;
        }