}
#endif /* OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32 */
+
+/* memory allocation functions for non-temporary storage
+ * (e.g. stuff that gets saved into the kssl context) */
+static void* kssl_calloc(size_t nmemb, size_t size)
+{
+ void* p;
+
+ p=OPENSSL_malloc(nmemb*size);
+ if (p){
+ memset(p, 0, nmemb*size);
+ }
+ return p;
+}
+
+#define kssl_malloc(size) OPENSSL_malloc((size))
+#define kssl_realloc(ptr, size) OPENSSL_realloc(ptr, size)
+#define kssl_free(ptr) OPENSSL_free((ptr))
+
+
char
*kstring(char *string)
{
KSSL_CTX *
kssl_ctx_new(void)
{
- return ((KSSL_CTX *) calloc(1, sizeof(KSSL_CTX)));
+ return ((KSSL_CTX *) kssl_calloc(1, sizeof(KSSL_CTX)));
}
if (kssl_ctx->key) OPENSSL_cleanse(kssl_ctx->key,
kssl_ctx->length);
- if (kssl_ctx->key) free(kssl_ctx->key);
- if (kssl_ctx->client_princ) free(kssl_ctx->client_princ);
- if (kssl_ctx->service_host) free(kssl_ctx->service_host);
- if (kssl_ctx->service_name) free(kssl_ctx->service_name);
- if (kssl_ctx->keytab_file) free(kssl_ctx->keytab_file);
+ if (kssl_ctx->key) kssl_free(kssl_ctx->key);
+ if (kssl_ctx->client_princ) kssl_free(kssl_ctx->client_princ);
+ if (kssl_ctx->service_host) kssl_free(kssl_ctx->service_host);
+ if (kssl_ctx->service_name) kssl_free(kssl_ctx->service_name);
+ if (kssl_ctx->keytab_file) kssl_free(kssl_ctx->keytab_file);
- free(kssl_ctx);
+ kssl_free(kssl_ctx);
return (KSSL_CTX *) NULL;
}
case KSSL_SERVER: princ = &kssl_ctx->service_host; break;
default: return KSSL_CTX_ERR; break;
}
- if (*princ) free(*princ);
+ if (*princ) kssl_free(*princ);
/* Add up all the entity->lengths */
length = 0;
/* Space for the ('@'+realm+NULL | NULL) */
length += ((realm)? realm->length + 2: 1);
- if ((*princ = calloc(1, length)) == NULL)
+ if ((*princ = kssl_calloc(1, length)) == NULL)
return KSSL_CTX_ERR;
else
{
case KSSL_KEYTAB: string = &kssl_ctx->keytab_file; break;
default: return KSSL_CTX_ERR; break;
}
- if (*string) free(*string);
+ if (*string) kssl_free(*string);
if (!text)
{
return KSSL_CTX_OK;
}
- if ((*string = calloc(1, strlen(text) + 1)) == NULL)
+ if ((*string = kssl_calloc(1, strlen(text) + 1)) == NULL)
return KSSL_CTX_ERR;
else
strcpy(*string, text);
if (kssl_ctx->key)
{
OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
- free(kssl_ctx->key);
+ kssl_free(kssl_ctx->key);
}
if (session)
}
if ((kssl_ctx->key =
- (krb5_octet FAR *) calloc(1, kssl_ctx->length)) == NULL)
+ (krb5_octet FAR *) kssl_calloc(1, kssl_ctx->length)) == NULL)
{
kssl_ctx->length = 0;
return KSSL_CTX_ERR;