diff options
| author | beck <> | 2002-05-15 02:29:21 +0000 |
|---|---|---|
| committer | beck <> | 2002-05-15 02:29:21 +0000 |
| commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
| tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/engine/enginetest.c | |
| parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
| download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip | |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/engine/enginetest.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c index a5a3c47fcb..87fa8c57b7 100644 --- a/src/lib/libcrypto/engine/enginetest.c +++ b/src/lib/libcrypto/engine/enginetest.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. |
| 7 | * | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
| @@ -56,8 +56,11 @@ | |||
| 56 | * | 56 | * |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <openssl/e_os2.h> | ||
| 59 | #include <stdio.h> | 60 | #include <stdio.h> |
| 60 | #include <string.h> | 61 | #include <string.h> |
| 62 | #include <openssl/buffer.h> | ||
| 63 | #include <openssl/crypto.h> | ||
| 61 | #include <openssl/engine.h> | 64 | #include <openssl/engine.h> |
| 62 | #include <openssl/err.h> | 65 | #include <openssl/err.h> |
| 63 | 66 | ||
| @@ -76,6 +79,9 @@ static void display_engine_list() | |||
| 76 | h = ENGINE_get_next(h); | 79 | h = ENGINE_get_next(h); |
| 77 | } | 80 | } |
| 78 | printf("end of list\n"); | 81 | printf("end of list\n"); |
| 82 | /* ENGINE_get_first() increases the struct_ref counter, so we | ||
| 83 | must call ENGINE_free() to decrease it again */ | ||
| 84 | ENGINE_free(h); | ||
| 79 | } | 85 | } |
| 80 | 86 | ||
| 81 | int main(int argc, char *argv[]) | 87 | int main(int argc, char *argv[]) |
| @@ -91,6 +97,18 @@ int main(int argc, char *argv[]) | |||
| 91 | ENGINE *new_h3 = NULL; | 97 | ENGINE *new_h3 = NULL; |
| 92 | ENGINE *new_h4 = NULL; | 98 | ENGINE *new_h4 = NULL; |
| 93 | 99 | ||
| 100 | /* enable memory leak checking unless explicitly disabled */ | ||
| 101 | if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))) | ||
| 102 | { | ||
| 103 | CRYPTO_malloc_debug_init(); | ||
| 104 | CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); | ||
| 105 | } | ||
| 106 | else | ||
| 107 | { | ||
| 108 | /* OPENSSL_DEBUG_MEMORY=off */ | ||
| 109 | CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0); | ||
| 110 | } | ||
| 111 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
| 94 | ERR_load_crypto_strings(); | 112 | ERR_load_crypto_strings(); |
| 95 | 113 | ||
| 96 | memset(block, 0, 512 * sizeof(ENGINE *)); | 114 | memset(block, 0, 512 * sizeof(ENGINE *)); |
| @@ -124,6 +142,8 @@ int main(int argc, char *argv[]) | |||
| 124 | printf("Remove failed!\n"); | 142 | printf("Remove failed!\n"); |
| 125 | goto end; | 143 | goto end; |
| 126 | } | 144 | } |
| 145 | if (ptr) | ||
| 146 | ENGINE_free(ptr); | ||
| 127 | display_engine_list(); | 147 | display_engine_list(); |
| 128 | if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) | 148 | if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) |
| 129 | { | 149 | { |
| @@ -158,12 +178,7 @@ int main(int argc, char *argv[]) | |||
| 158 | } | 178 | } |
| 159 | else | 179 | else |
| 160 | printf("Remove that should fail did.\n"); | 180 | printf("Remove that should fail did.\n"); |
| 161 | if(!ENGINE_remove(new_h1)) | 181 | ERR_clear_error(); |
| 162 | { | ||
| 163 | printf("Remove failed!\n"); | ||
| 164 | goto end; | ||
| 165 | } | ||
| 166 | display_engine_list(); | ||
| 167 | if(!ENGINE_remove(new_h3)) | 182 | if(!ENGINE_remove(new_h3)) |
| 168 | { | 183 | { |
| 169 | printf("Remove failed!\n"); | 184 | printf("Remove failed!\n"); |
| @@ -183,6 +198,8 @@ int main(int argc, char *argv[]) | |||
| 183 | if(!ENGINE_remove(ptr)) | 198 | if(!ENGINE_remove(ptr)) |
| 184 | printf("Remove failed!i - probably no hardware " | 199 | printf("Remove failed!i - probably no hardware " |
| 185 | "support present.\n"); | 200 | "support present.\n"); |
| 201 | if (ptr) | ||
| 202 | ENGINE_free(ptr); | ||
| 186 | display_engine_list(); | 203 | display_engine_list(); |
| 187 | if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) | 204 | if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) |
| 188 | { | 205 | { |
| @@ -195,9 +212,9 @@ int main(int argc, char *argv[]) | |||
| 195 | for(loop = 0; loop < 512; loop++) | 212 | for(loop = 0; loop < 512; loop++) |
| 196 | { | 213 | { |
| 197 | sprintf(buf, "id%i", loop); | 214 | sprintf(buf, "id%i", loop); |
| 198 | id = strdup(buf); | 215 | id = BUF_strdup(buf); |
| 199 | sprintf(buf, "Fake engine type %i", loop); | 216 | sprintf(buf, "Fake engine type %i", loop); |
| 200 | name = strdup(buf); | 217 | name = BUF_strdup(buf); |
| 201 | if(((block[loop] = ENGINE_new()) == NULL) || | 218 | if(((block[loop] = ENGINE_new()) == NULL) || |
| 202 | !ENGINE_set_id(block[loop], id) || | 219 | !ENGINE_set_id(block[loop], id) || |
| 203 | !ENGINE_set_name(block[loop], name)) | 220 | !ENGINE_set_name(block[loop], name)) |
| @@ -228,12 +245,13 @@ cleanup_loop: | |||
| 228 | printf("\nRemove failed!\n"); | 245 | printf("\nRemove failed!\n"); |
| 229 | goto end; | 246 | goto end; |
| 230 | } | 247 | } |
| 248 | ENGINE_free(ptr); | ||
| 231 | printf("."); fflush(stdout); | 249 | printf("."); fflush(stdout); |
| 232 | } | 250 | } |
| 233 | for(loop = 0; loop < 512; loop++) | 251 | for(loop = 0; loop < 512; loop++) |
| 234 | { | 252 | { |
| 235 | free((char *)(ENGINE_get_id(block[loop]))); | 253 | OPENSSL_free((void *)ENGINE_get_id(block[loop])); |
| 236 | free((char *)(ENGINE_get_name(block[loop]))); | 254 | OPENSSL_free((void *)ENGINE_get_name(block[loop])); |
| 237 | } | 255 | } |
| 238 | printf("\nTests completed happily\n"); | 256 | printf("\nTests completed happily\n"); |
| 239 | to_return = 0; | 257 | to_return = 0; |
| @@ -247,5 +265,10 @@ end: | |||
| 247 | for(loop = 0; loop < 512; loop++) | 265 | for(loop = 0; loop < 512; loop++) |
| 248 | if(block[loop]) | 266 | if(block[loop]) |
| 249 | ENGINE_free(block[loop]); | 267 | ENGINE_free(block[loop]); |
| 268 | ENGINE_cleanup(); | ||
| 269 | CRYPTO_cleanup_all_ex_data(); | ||
| 270 | ERR_free_strings(); | ||
| 271 | ERR_remove_state(0); | ||
| 272 | CRYPTO_mem_leaks_fp(stderr); | ||
| 250 | return to_return; | 273 | return to_return; |
| 251 | } | 274 | } |
