s3:registry: flush the provided subkey_ctr in regdb_fetch_keys_internal()
authorMichael Adam <obnox@samba.org>
Wed, 15 Jul 2009 10:50:55 +0000 (12:50 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 15 Jul 2009 12:01:58 +0000 (14:01 +0200)
This way, we always return what has really been read from the db,
and not more. The callers assume exactly this, but one could hand
in an already pre-filled subkey container...

Michael

source3/registry/reg_backend_db.c

index 7825edd5c252689597911b78c41b326a59a89ac3..9fd5c3161b04af5deda75eab0b4cc99899fbecaa 100644 (file)
@@ -1474,6 +1474,9 @@ static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key,
        buflen = value.dsize;
        len = tdb_unpack( buf, buflen, "d", &num_items);
 
+       werr = regsubkey_ctr_reinit(ctr);
+       W_ERROR_NOT_OK_GOTO_DONE(werr);
+
        for (i=0; i<num_items; i++) {
                len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
                werr = regsubkey_ctr_addkey(ctr, subkeyname);