-/* dso_win32.c -*- mode:C; c-file-style: "eay" -*- */
/*
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
* 2000.
#include <stdio.h>
#include <string.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
#include <openssl/dso.h>
#if !defined(DSO_WIN32)
ERR_add_error_data(3, "filename(", filename, ")");
goto err;
}
- p = (HINSTANCE *) OPENSSL_malloc(sizeof(HINSTANCE));
+ p = OPENSSL_malloc(sizeof(*p));
if (p == NULL) {
DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE);
goto err;
return (1);
err:
/* Cleanup ! */
- if (filename != NULL)
- OPENSSL_free(filename);
- if (p != NULL)
- OPENSSL_free(p);
+ OPENSSL_free(filename);
+ OPENSSL_free(p);
if (h != NULL)
FreeLibrary(h);
return (0);
static void *win32_bind_var(DSO *dso, const char *symname)
{
HINSTANCE *ptr;
- void *sym;
+ union {
+ void *p;
+ FARPROC f;
+ } sym;
if ((dso == NULL) || (symname == NULL)) {
DSOerr(DSO_F_WIN32_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
DSOerr(DSO_F_WIN32_BIND_VAR, DSO_R_NULL_HANDLE);
return (NULL);
}
- sym = GetProcAddress(*ptr, symname);
- if (sym == NULL) {
+ sym.f = GetProcAddress(*ptr, symname);
+ if (sym.p == NULL) {
DSOerr(DSO_F_WIN32_BIND_VAR, DSO_R_SYM_FAILURE);
ERR_add_error_data(3, "symname(", symname, ")");
return (NULL);
}
- return (sym);
+ return (sym.p);
}
static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
{
HINSTANCE *ptr;
- void *sym;
+ union {
+ void *p;
+ FARPROC f;
+ } sym;
if ((dso == NULL) || (symname == NULL)) {
DSOerr(DSO_F_WIN32_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER);
DSOerr(DSO_F_WIN32_BIND_FUNC, DSO_R_NULL_HANDLE);
return (NULL);
}
- sym = GetProcAddress(*ptr, symname);
- if (sym == NULL) {
+ sym.f = GetProcAddress(*ptr, symname);
+ if (sym.p == NULL) {
DSOerr(DSO_F_WIN32_BIND_FUNC, DSO_R_SYM_FAILURE);
ERR_add_error_data(3, "symname(", symname, ")");
return (NULL);
}
- return ((DSO_FUNC_TYPE)sym);
+ return ((DSO_FUNC_TYPE)sym.f);
}
struct file_st {
return (NULL);
}
- result = OPENSSL_malloc(sizeof(struct file_st));
+ result = OPENSSL_zalloc(sizeof(*result));
if (result == NULL) {
DSOerr(DSO_F_WIN32_SPLITTER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(result, 0, sizeof(struct file_st));
position = IN_DEVICE;
if ((filename[0] == '\\' && filename[1] == '\\')
}
result = OPENSSL_malloc(len + 1);
- if (!result) {
+ if (result == NULL) {
DSOerr(DSO_F_WIN32_JOINER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
}
if (!filespec2) {
merged = OPENSSL_malloc(strlen(filespec1) + 1);
- if (!merged) {
+ if (merged == NULL) {
DSOerr(DSO_F_WIN32_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
strcpy(merged, filespec1);
} else if (!filespec1) {
merged = OPENSSL_malloc(strlen(filespec2) + 1);
- if (!merged) {
+ if (merged == NULL) {
DSOerr(DSO_F_WIN32_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
CREATETOOLHELP32SNAPSHOT create_snap;
CLOSETOOLHELP32SNAPSHOT close_snap;
MODULE32 module_first, module_next;
- FARPROC ret = NULL;
+ union {
+ void *p;
+ FARPROC f;
+ } ret = { NULL };
dll = LoadLibrary(TEXT(DLLNAME));
if (dll == NULL) {
}
do {
- if ((ret = GetProcAddress(me32.hModule, name))) {
+ if ((ret.f = GetProcAddress(me32.hModule, name))) {
(*close_snap) (hModuleSnap);
FreeLibrary(dll);
- return ret;
+ return ret.p;
}
} while ((*module_next) (hModuleSnap, &me32));