X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=crypto%2Fdso%2Fdso_win32.c;h=3d9ee8a5580fe562d5a2187af006535b2db5b496;hb=a89c9a0d855bce735116acfe147b24e386f566ba;hp=144d8e63c33ad5bea8033fa762afaabbcf5b6a8b;hpb=b548a1f11c06ccdfa4f52a539912d22d77ee309e;p=openssl.git diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index 144d8e63c3..3d9ee8a558 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -1,4 +1,3 @@ -/* dso_win32.c -*- mode:C; c-file-style: "eay" -*- */ /* * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project * 2000. @@ -59,7 +58,7 @@ #include #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #if !defined(DSO_WIN32) @@ -168,7 +167,7 @@ static int win32_load(DSO *dso) ERR_add_error_data(3, "filename(", filename, ")"); goto err; } - p = OPENSSL_malloc(sizeof(HINSTANCE)); + p = OPENSSL_malloc(sizeof(*p)); if (p == NULL) { DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE); goto err; @@ -224,7 +223,10 @@ static int win32_unload(DSO *dso) 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); @@ -239,19 +241,22 @@ static void *win32_bind_var(DSO *dso, const char *symname) 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); @@ -266,13 +271,13 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname) 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 { @@ -304,13 +309,12 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, 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] == '\\') @@ -428,7 +432,7 @@ static char *win32_joiner(DSO *dso, const struct file_st *file_split) } result = OPENSSL_malloc(len + 1); - if (!result) { + if (result == NULL) { DSOerr(DSO_F_WIN32_JOINER, ERR_R_MALLOC_FAILURE); return (NULL); } @@ -494,14 +498,14 @@ static char *win32_merger(DSO *dso, const char *filespec1, } 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); } @@ -705,7 +709,10 @@ static void *win32_globallookup(const char *name) 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) { @@ -746,10 +753,10 @@ static void *win32_globallookup(const char *name) } 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));