avoid infinite recursion if dynamic engine isn't loaded
authorNils Larsch <nils@openssl.org>
Sat, 6 Aug 2005 10:34:35 +0000 (10:34 +0000)
committerNils Larsch <nils@openssl.org>
Sat, 6 Aug 2005 10:34:35 +0000 (10:34 +0000)
Submitted by: Jonathon Green <jonathon_au@yahoo.com>

crypto/engine/eng_list.c

index f337e0f3bc650b548d0c7fecbf551ac8a9abfddb..bd511944bafdabbfabf34b0e96adced573cf9d97 100644 (file)
@@ -394,19 +394,23 @@ ENGINE *ENGINE_by_id(const char *id)
 #else
        /* EEK! Experimental code starts */
        if(iterator) return iterator;
+       /* Prevent infinite recusrion if we're looking for the dynamic engine. */
+       if (strcmp(id, "dynamic"))
+               {
 #ifdef OPENSSL_SYS_VMS
-       if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = "SSLROOT:[ENGINES]";
+               if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = "SSLROOT:[ENGINES]";
 #else
-       if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = ENGINESDIR;
+               if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = ENGINESDIR;
 #endif
-       iterator = ENGINE_by_id("dynamic");
-       if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
-                       !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
-                       !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD",
-                               load_dir, 0) ||
-                       !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0))
-               goto notfound;
-       return iterator;
+               iterator = ENGINE_by_id("dynamic");
+               if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
+                               !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
+                               !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD",
+                                       load_dir, 0) ||
+                               !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0))
+                               goto notfound;
+               return iterator;
+               }
 notfound:
        ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE);
        ERR_add_error_data(2, "id=", id);