tolerate broken CMS/PKCS7 implementations using signature OID instead of digest
[oweals/openssl.git] / crypto / engine / eng_table.c
index 0c1656168d50d60ed45a8bfdd6889eb4e089f6f4..8fc47b3399c8982384e76c1ecc8bc1d8a77777fb 100644 (file)
@@ -135,7 +135,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
                        {
                        fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
                        if(!fnd) goto end;
-                       fnd->uptodate = 0;
+                       fnd->uptodate = 1;
                        fnd->nid = *nids;
                        fnd->sk = sk_ENGINE_new_null();
                        if(!fnd->sk)
@@ -152,7 +152,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
                if(!sk_ENGINE_push(fnd->sk, e))
                        goto end;
                /* "touch" this ENGINE_PILE */
-               fnd->uptodate = 1;
+               fnd->uptodate = 0;
                if(setdefault)
                        {
                        if(!engine_unlocked_init(e))
@@ -164,6 +164,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
                        if(fnd->funct)
                                engine_unlocked_finish(fnd->funct, 0);
                        fnd->funct = e;
+                       fnd->uptodate = 1;
                        }
                nids++;
                }
@@ -179,8 +180,7 @@ static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
        while((n = sk_ENGINE_find(pile->sk, e)) >= 0)
                {
                (void)sk_ENGINE_delete(pile->sk, n);
-               /* "touch" this ENGINE_CIPHER */
-               pile->uptodate = 1;
+               pile->uptodate = 0;
                }
        if(pile->funct == e)
                {
@@ -237,6 +237,7 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, in
 #endif
                return NULL;
                }
+       ERR_set_mark();
        CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        /* Check again inside the lock otherwise we could race against cleanup
         * operations. But don't worry about a fprintf(stderr). */
@@ -310,6 +311,6 @@ end:
        CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Whatever happened, any failed init()s are not failures in this
         * context, so clear our error state. */
-       ERR_clear_error();
+       ERR_pop_to_mark();
        return ret;
        }