summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2014-04-21 09:23:41 +0000
committerderaadt <>2014-04-21 09:23:41 +0000
commite0b69e899ac1d0bee0a300745f95032b228a9cab (patch)
tree7e79551f2f9dbd68f365283703ac365a2ba39350
parent2136a925bd7596118fa98134cae7dd4a5edfbed8 (diff)
downloadopenbsd-e0b69e899ac1d0bee0a300745f95032b228a9cab.tar.gz
openbsd-e0b69e899ac1d0bee0a300745f95032b228a9cab.tar.bz2
openbsd-e0b69e899ac1d0bee0a300745f95032b228a9cab.zip
remove macros wrapping malloc/calloc/free/realloc
-rw-r--r--src/lib/libssl/src/ssl/kssl.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/lib/libssl/src/ssl/kssl.c b/src/lib/libssl/src/ssl/kssl.c
index 26597f258e..b4ddab7597 100644
--- a/src/lib/libssl/src/ssl/kssl.c
+++ b/src/lib/libssl/src/ssl/kssl.c
@@ -84,13 +84,6 @@
84#define ENOMEM KRB5KRB_ERR_GENERIC 84#define ENOMEM KRB5KRB_ERR_GENERIC
85#endif 85#endif
86 86
87
88#define kssl_malloc(size) malloc((size))
89#define kssl_calloc(nmemb, size) calloc(nmemb, size)
90#define kssl_realloc(ptr, size) realloc(ptr, size)
91#define kssl_free(ptr) free((ptr))
92
93
94char * 87char *
95kstring(char *string) 88kstring(char *string)
96{ 89{
@@ -558,8 +551,7 @@ kssl_TKT2tkt(
558 return KRB5KRB_ERR_GENERIC; 551 return KRB5KRB_ERR_GENERIC;
559 } 552 }
560 553
561 if ((new5ticket = 554 if ((new5ticket = calloc(1, sizeof(krb5_ticket))) == NULL) {
562 (krb5_ticket *)calloc(1, sizeof(krb5_ticket))) == NULL) {
563 (void) snprintf(kssl_err->text, KSSL_ERR_MAX, 555 (void) snprintf(kssl_err->text, KSSL_ERR_MAX,
564 "Unable to allocate new krb5_ticket.\n"); 556 "Unable to allocate new krb5_ticket.\n");
565 kssl_err->reason = SSL_R_KRB5_S_RD_REQ; 557 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
@@ -849,7 +841,7 @@ err:
849KSSL_CTX * 841KSSL_CTX *
850kssl_ctx_new(void) 842kssl_ctx_new(void)
851{ 843{
852 return ((KSSL_CTX *) kssl_calloc(1, sizeof(KSSL_CTX))); 844 return (calloc(1, sizeof(KSSL_CTX)));
853} 845}
854 846
855 847
@@ -865,17 +857,17 @@ kssl_ctx_free(KSSL_CTX *kssl_ctx)
865 if (kssl_ctx->key) 857 if (kssl_ctx->key)
866 OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length); 858 OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
867 if (kssl_ctx->key) 859 if (kssl_ctx->key)
868 kssl_free(kssl_ctx->key); 860 free(kssl_ctx->key);
869 if (kssl_ctx->client_princ) 861 if (kssl_ctx->client_princ)
870 kssl_free(kssl_ctx->client_princ); 862 free(kssl_ctx->client_princ);
871 if (kssl_ctx->service_host) 863 if (kssl_ctx->service_host)
872 kssl_free(kssl_ctx->service_host); 864 free(kssl_ctx->service_host);
873 if (kssl_ctx->service_name) 865 if (kssl_ctx->service_name)
874 kssl_free(kssl_ctx->service_name); 866 free(kssl_ctx->service_name);
875 if (kssl_ctx->keytab_file) 867 if (kssl_ctx->keytab_file)
876 kssl_free(kssl_ctx->keytab_file); 868 free(kssl_ctx->keytab_file);
877 869
878 kssl_free(kssl_ctx); 870 free(kssl_ctx);
879 return (KSSL_CTX *) NULL; 871 return (KSSL_CTX *) NULL;
880} 872}
881 873
@@ -907,7 +899,7 @@ kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, krb5_data *realm,
907 break; 899 break;
908 } 900 }
909 if (*princ) 901 if (*princ)
910 kssl_free(*princ); 902 free(*princ);
911 903
912 /* Add up all the entity->lengths */ 904 /* Add up all the entity->lengths */
913 length = 0; 905 length = 0;
@@ -919,7 +911,7 @@ kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, krb5_data *realm,
919 /* Space for the ('@'+realm+NULL | NULL) */ 911 /* Space for the ('@'+realm+NULL | NULL) */
920 length += ((realm) ? realm->length + 2 : 1); 912 length += ((realm) ? realm->length + 2 : 1);
921 913
922 if ((*princ = kssl_calloc(1, length)) == NULL) 914 if ((*princ = calloc(1, length)) == NULL)
923 return KSSL_CTX_ERR; 915 return KSSL_CTX_ERR;
924 else { 916 else {
925 for (i = 0; i < nentities; i++) { 917 for (i = 0; i < nentities; i++) {
@@ -969,14 +961,14 @@ kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text)
969 break; 961 break;
970 } 962 }
971 if (*string) 963 if (*string)
972 kssl_free(*string); 964 free(*string);
973 965
974 if (!text) { 966 if (!text) {
975 *string = '\0'; 967 *string = '\0';
976 return KSSL_CTX_OK; 968 return KSSL_CTX_OK;
977 } 969 }
978 970
979 if ((*string = kssl_calloc(1, strlen(text) + 1)) == NULL) 971 if ((*string = calloc(1, strlen(text) + 1)) == NULL)
980 return KSSL_CTX_ERR; 972 return KSSL_CTX_ERR;
981 else 973 else
982 memcpy(*string, text, strlen(text) + 1); 974 memcpy(*string, text, strlen(text) + 1);
@@ -1000,7 +992,7 @@ kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)
1000 992
1001 if (kssl_ctx->key) { 993 if (kssl_ctx->key) {
1002 OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length); 994 OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
1003 kssl_free(kssl_ctx->key); 995 free(kssl_ctx->key);
1004 } 996 }
1005 997
1006 if (session) { 998 if (session) {
@@ -1022,8 +1014,7 @@ kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)
1022 return KSSL_CTX_OK; 1014 return KSSL_CTX_OK;
1023 } 1015 }
1024 1016
1025 if ((kssl_ctx->key = 1017 if ((kssl_ctx->key = calloc(1, kssl_ctx->length)) == NULL) {
1026 (krb5_octet FAR *)kssl_calloc(1, kssl_ctx->length)) == NULL) {
1027 kssl_ctx->length = 0; 1018 kssl_ctx->length = 0;
1028 return KSSL_CTX_ERR; 1019 return KSSL_CTX_ERR;
1029 } else 1020 } else
@@ -1501,9 +1492,8 @@ kssl_build_principal_2(
1501 krb5_principal new_p = NULL; 1492 krb5_principal new_p = NULL;
1502 char *new_r = NULL; 1493 char *new_r = NULL;
1503 1494
1504 if ((p_data = (krb5_data *)calloc(2, sizeof(krb5_data))) == NULL || 1495 if ((p_data = calloc(2, sizeof(krb5_data))) == NULL ||
1505 (new_p = (krb5_principal)calloc(1, sizeof(krb5_principal_data))) == 1496 (new_p = calloc(1, sizeof(krb5_principal_data))) == NULL)
1506 NULL)
1507 goto err; 1497 goto err;
1508 new_p->length = 2; 1498 new_p->length = 2;
1509 new_p->data = p_data; 1499 new_p->data = p_data;