mirror of
https://github.com/mtrojnar/osslsigncode.git
synced 2025-07-02 19:22:47 -05:00
Code simplification
No functional change intended.
This commit is contained in:
@ -4125,7 +4125,7 @@ static int read_pkcs7_certfile(GLOBAL_OPTIONS *options)
|
|||||||
* [in] options: structure holds the input data
|
* [in] options: structure holds the input data
|
||||||
* [returns] pointer to ENGINE
|
* [returns] pointer to ENGINE
|
||||||
*/
|
*/
|
||||||
static ENGINE *engine_dynamic(GLOBAL_OPTIONS *options)
|
static ENGINE *engine_dynamic(const char *path)
|
||||||
{
|
{
|
||||||
ENGINE *engine;
|
ENGINE *engine;
|
||||||
char *id;
|
char *id;
|
||||||
@ -4135,18 +4135,18 @@ static ENGINE *engine_dynamic(GLOBAL_OPTIONS *options)
|
|||||||
fprintf(stderr, "Failed to load 'dynamic' engine\n");
|
fprintf(stderr, "Failed to load 'dynamic' engine\n");
|
||||||
return NULL; /* FAILED */
|
return NULL; /* FAILED */
|
||||||
}
|
}
|
||||||
if (options->p11engine) { /* strip directory and extension */
|
if (path) { /* strip directory and extension */
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
ptr = strrchr(options->p11engine, '/');
|
ptr = strrchr(path, '/');
|
||||||
if (!ptr) /* no slash -> try backslash */
|
if (!ptr) /* no slash -> try backslash */
|
||||||
ptr = strrchr(options->p11engine, '\\');
|
ptr = strrchr(path, '\\');
|
||||||
if (ptr) { /* directory separator found */
|
if (ptr) { /* directory separator found */
|
||||||
ptr++; /* skip it */
|
ptr++; /* skip it */
|
||||||
if (!strncmp(ptr, "lib", 3))
|
if (!strncmp(ptr, "lib", 3))
|
||||||
ptr += 3; /* skip the "lib" prefix */
|
ptr += 3; /* skip the "lib" prefix */
|
||||||
} else /* directory separator not found */
|
} else /* directory separator not found */
|
||||||
ptr = options->p11engine;
|
ptr = (char *)path;
|
||||||
id = OPENSSL_strdup(ptr);
|
id = OPENSSL_strdup(ptr);
|
||||||
ptr = strchr(id, '.');
|
ptr = strchr(id, '.');
|
||||||
if (ptr) /* file extensions found */
|
if (ptr) /* file extensions found */
|
||||||
@ -4154,7 +4154,7 @@ static ENGINE *engine_dynamic(GLOBAL_OPTIONS *options)
|
|||||||
} else {
|
} else {
|
||||||
id = OPENSSL_strdup("pkcs11");
|
id = OPENSSL_strdup("pkcs11");
|
||||||
}
|
}
|
||||||
if (!ENGINE_ctrl_cmd_string(engine, "SO_PATH", options->p11engine, 0)
|
if (!ENGINE_ctrl_cmd_string(engine, "SO_PATH", path, 0)
|
||||||
|| !ENGINE_ctrl_cmd_string(engine, "ID", id, 0)
|
|| !ENGINE_ctrl_cmd_string(engine, "ID", id, 0)
|
||||||
|| !ENGINE_ctrl_cmd_string(engine, "LIST_ADD", "1", 0)
|
|| !ENGINE_ctrl_cmd_string(engine, "LIST_ADD", "1", 0)
|
||||||
|| !ENGINE_ctrl_cmd_string(engine, "LOAD", NULL, 0)) {
|
|| !ENGINE_ctrl_cmd_string(engine, "LOAD", NULL, 0)) {
|
||||||
@ -4250,7 +4250,7 @@ static int engine_load(GLOBAL_OPTIONS *options)
|
|||||||
|
|
||||||
if (strchr(id, '.')) {
|
if (strchr(id, '.')) {
|
||||||
/* Treat strings with a dot as paths to dynamic engine modules */
|
/* Treat strings with a dot as paths to dynamic engine modules */
|
||||||
engine = engine_dynamic(options);
|
engine = engine_dynamic(id);
|
||||||
} else {
|
} else {
|
||||||
/* Treat strings without a dot as engine IDs */
|
/* Treat strings without a dot as engine IDs */
|
||||||
engine = ENGINE_by_id(id);
|
engine = ENGINE_by_id(id);
|
||||||
|
Reference in New Issue
Block a user