diff options
author | tedu <> | 2014-04-23 21:01:15 +0000 |
---|---|---|
committer | tedu <> | 2014-04-23 21:01:15 +0000 |
commit | 05c2a6d2a67f4058252e7cf649b4a96ae3b242be (patch) | |
tree | 8550a14418d1536a29b400dc8e0f28dd47667c71 | |
parent | 2200007b52bd1fa0d16b0f986bb90e51ec5fcf01 (diff) | |
download | openbsd-05c2a6d2a67f4058252e7cf649b4a96ae3b242be.tar.gz openbsd-05c2a6d2a67f4058252e7cf649b4a96ae3b242be.tar.bz2 openbsd-05c2a6d2a67f4058252e7cf649b4a96ae3b242be.zip |
null pointers after free to prevent double frees and worse. also fix a
very obvious use after free. this file may still be a total loss.
-rw-r--r-- | src/lib/libssl/src/ssl/kssl.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/lib/libssl/src/ssl/kssl.c b/src/lib/libssl/src/ssl/kssl.c index b4ddab7597..9e71eed9fa 100644 --- a/src/lib/libssl/src/ssl/kssl.c +++ b/src/lib/libssl/src/ssl/kssl.c | |||
@@ -898,8 +898,8 @@ kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, krb5_data *realm, | |||
898 | return KSSL_CTX_ERR; | 898 | return KSSL_CTX_ERR; |
899 | break; | 899 | break; |
900 | } | 900 | } |
901 | if (*princ) | 901 | free(*princ); |
902 | free(*princ); | 902 | *princ = NULL; |
903 | 903 | ||
904 | /* Add up all the entity->lengths */ | 904 | /* Add up all the entity->lengths */ |
905 | length = 0; | 905 | length = 0; |
@@ -960,18 +960,11 @@ kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text) | |||
960 | return KSSL_CTX_ERR; | 960 | return KSSL_CTX_ERR; |
961 | break; | 961 | break; |
962 | } | 962 | } |
963 | if (*string) | 963 | free(*string); |
964 | free(*string); | 964 | *string = NULL; |
965 | 965 | ||
966 | if (!text) { | 966 | if ((*string = strdup(text ? text : "")) == NULL) |
967 | *string = '\0'; | ||
968 | return KSSL_CTX_OK; | ||
969 | } | ||
970 | |||
971 | if ((*string = calloc(1, strlen(text) + 1)) == NULL) | ||
972 | return KSSL_CTX_ERR; | 967 | return KSSL_CTX_ERR; |
973 | else | ||
974 | memcpy(*string, text, strlen(text) + 1); | ||
975 | 968 | ||
976 | return KSSL_CTX_OK; | 969 | return KSSL_CTX_OK; |
977 | } | 970 | } |
@@ -993,6 +986,7 @@ kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session) | |||
993 | if (kssl_ctx->key) { | 986 | if (kssl_ctx->key) { |
994 | OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length); | 987 | OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length); |
995 | free(kssl_ctx->key); | 988 | free(kssl_ctx->key); |
989 | kssl_ctx->key = NULL; | ||
996 | } | 990 | } |
997 | 991 | ||
998 | if (session) { | 992 | if (session) { |