apply patches to original opensource openssl-3.5.0. NOTE: This commit will NOT COMPILE. (#17)

Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/17
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
2026-07-30 19:33:32 +05:30
committed by neelimap
parent 1fa225b5aa
commit 23ab638c92
91 changed files with 1792 additions and 108 deletions
@@ -21,20 +21,6 @@
#ifdef DSO_DLFCN
# ifdef HAVE_DLFCN_H
# ifdef __osf__
# define __EXTENSIONS__
# endif
# include <dlfcn.h>
# define HAVE_DLINFO 1
# if defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
(defined(__osf__) && !defined(RTLD_NEXT)) || \
(defined(__OpenBSD__) && !defined(RTLD_SELF)) || \
defined(__ANDROID__) || defined(__TANDEM)
# undef HAVE_DLINFO
# endif
# endif
/* Part of the hack in "dlfcn_load" ... */
# define DSO_MAX_TRANSLATED_SIZE 256
@@ -66,6 +52,449 @@ DSO_METHOD *DSO_METHOD_openssl(void)
return &dso_meth_dlfcn;
}
#if defined (_WRS_KERNEL)
#ifdef HOST
#ifndef WIN32
#include <strings.h>
#endif /* WIN32 */
#include <host.h>
#include <vmutex.h>
#include <sysSymTbl.h>
#else /* !HOST */
#include <vxWorks.h>
#include <semLib.h>
#include <memLib.h>
#include <memPartLib.h>
#include <private/hashLibP.h>
#include <ffsLib.h>
#ifdef _WRS_CONFIG_LOADER
#include <elf.h>
#include <elftypes.h>
#include <private/loadRtpLibP.h> /* _func_loadRtp* */
#include <moduleLib.h>
#include <loadLib.h>
#include <loadElfLib.h>
#endif /* _WRS_CONFIG_LOADER */
#ifdef _WRS_KERNEL
#include <sysSymTbl.h>
#else /* !_WRS_KERNEL */
#include <strings.h>
#endif /* _WRS_KERNEL */
#endif /* HOST */
#include <hashLib.h>
#include <private/symLibP.h>
#include <private/symbolP.h>
#include <errnoLib.h>
#include <symLib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ffsLib.h>
typedef struct symkey
{
char * name;
MODULE_ID moptr;
}SYMKEY;
typedef struct symFdStore
{
SL_NODE pSymStore;
MODULE_ID moptr;
int fd;
}SYMFDSTORE;
LOCAL SYM_VALUE symVal;
LOCAL UINT symLkupPgSz = 21;
LOCAL SL_LIST symFdList;
LOCAL BOOL isInit = FALSE;
LOCAL char * strMatch
(
char * str1, /* where to look for match */
char * str2 /* string to find a match for */
)
{
size_t str2Length = strlen (str2);
ssize_t ntries = strlen (str1) - str2Length;
for (; ntries >= 0; str1++, --ntries)
{
if (strncmp (str1, str2, str2Length) == 0)
return (str1);
}
return (NULL);
}
LOCAL BOOL symNodeEach
(
SL_NODE * pNode,
_Vx_usr_arg_t ptr
)
{
SYMFDSTORE * pStore = (SYMFDSTORE *)pNode;
if (pStore->moptr == ptr)
return FALSE;
return TRUE;
}
LOCAL BOOL symSysTbllk
(
char * name, /* symbol name */
SYM_VALUE val, /* symbol value */
SYM_TYPE type, /* symbol type */
_Vx_usr_arg_t substrArg, /* substring to match */
SYM_GROUP group, /* symbol's module group */
SYMBOL * pSymbol /* symbol structure */
)
{
char moduleName [NAME_MAX];
#ifdef _WRS_CONFIG_LOADER
MODULE_ID moduleId = (MODULE_ID) pSymbol->symRef;
#endif
char * nameToPrint = name;
char quitChar;
SYMKEY * pSymKey = (SYMKEY *) substrArg;
#ifdef _WRS_CONFIG_LOADER
if (((SYM_REF)moduleId != SYMREF_NONE) &&
((SYM_REF)moduleId != SYMREF_SHELL) &&
((SYM_REF)moduleId != SYMREF_KERNEL) &&
((SYM_REF)moduleId != SYMREF_WTX) &&
moduleIdVerify (moduleId) == OK)
{
}
else
#endif /* _WRS_CONFIG_LOADER */
moduleName [0] = EOS;
if (strMatch (name, pSymKey->name) != NULL)
{
#ifdef _WRS_CONFIG_CPLUS_KERNEL
char demangled [MAX_SYS_SYM_LEN + 1];
nameToPrint = cplusDemangle (name, demangled, sizeof (demangled));
#endif
if (type & SYM_LOCAL)
{
return TRUE;
}
if (pSymKey->moptr == moduleId)
{
symVal = val;
return FALSE;
}
}
return (TRUE);
}
LOCAL SYM_VALUE symlkup
(
SYMTAB_ID pSymTbl,
SYMKEY * pSymKey
)
{
BOOL isRtpSymbolTable = FALSE;
if (pSymKey == NULL)
{
}
else
{
if (pSymTbl == sysSymTbl)
{
symEach (pSymTbl, (SYM_EACH_RTN_FUNCPTR)symSysTbllk,
(_Vx_usr_arg_t) pSymKey);
}
}
return symVal;
}
static int dlfcn_load(DSO *dso)
{
void * ptr = NULL;
char * filename = DSO_convert_filename(dso, NULL);
int saveerrno = get_last_sys_error();
int fd;
SL_NODE * pSymStore = NULL;
if (!isInit)
{
(void) sllInit (&symFdList);
isInit = TRUE;
}
if (filename == NULL)
{
ERR_raise(ERR_LIB_DSO, DSO_R_NO_FILENAME);
return (0);
}
fd = open (filename, O_RDONLY, 0);
if (fd == ERROR)
{
return (0);
}
ptr = loadModule (fd, LOAD_GLOBAL_SYMBOLS);
if (ptr == NULL)
{
ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
"filename(%s):", filename);
goto err;
}
set_sys_error(saveerrno);
if (!sk_void_push(dso->meth_data, (char *)ptr))
{
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
goto err;
}
/* Success */
dso->loaded_filename = filename;
pSymStore = (SL_NODE *) malloc (sizeof (SYMFDSTORE));
if (pSymStore == NULL)
{
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
goto err;
}
((SYMFDSTORE *)pSymStore)->moptr = ptr;
((SYMFDSTORE *)pSymStore)->fd = fd;
sllPutAtTail (&symFdList, pSymStore);
return 1;
err:
/* Cleanup! */
OPENSSL_free(filename);
if (ptr != NULL)
unldByModuleId(ptr, 0);
return 0;
}
static int dlfcn_unload(DSO *dso)
{
void * ptr;
SL_NODE * pStore;
SL_NODE * pPrevNode;
if (dso == NULL)
{
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
if (sk_void_num(dso->meth_data) < 1)
return 1;
ptr = sk_void_pop(dso->meth_data);
if (ptr == NULL)
{
ERR_raise(ERR_LIB_DSO, DSO_R_NULL_HANDLE);
/*
* Should push the value back onto the stack in case of a retry.
*/
sk_void_push(dso->meth_data, ptr);
return 0;
}
/* For now I'm not aware of any errors associated with dlclose() */
unldByModuleId(ptr, 0);
pStore = sllEach (&symFdList,
symNodeEach,
(_Vx_usr_arg_t)ptr);
if (pStore == NULL)
{
return 0;
}
pPrevNode = sllPrevious (&symFdList, pStore);
close (((SYMFDSTORE *)pStore)->fd);
sllRemove (&symFdList, pStore, pPrevNode);
free (pStore);
return 1;
}
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
{
SYMKEY symKey;
void * ptr;
SYMFDSTORE * pSymStore = NULL;
union {
DSO_FUNC_TYPE sym;
void *dlret;
} u;
if ((dso == NULL) || (symname == NULL))
{
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
if (sk_void_num(dso->meth_data) < 1)
{
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
return NULL;
}
ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
if (ptr == NULL)
{
ERR_raise(ERR_LIB_DSO, DSO_R_NULL_HANDLE);
return NULL;
}
pSymStore = (SYMFDSTORE *) sllEach (&symFdList,
symNodeEach,
(_Vx_usr_arg_t)ptr);
symKey.name = symname;
symKey.moptr = ptr;
u.sym = symlkup(sysSymTbl, &symKey);
if (u.sym == NULL)
{
printf("symname(%s): ", symname);
return NULL;
}
return u.sym;
}
static char *dlfcn_merger
(
DSO * dso,
const char * filespec1,
const char * filespec2
)
{
char *merged;
if (!filespec1 && !filespec2)
{
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
/*
* If the first file specification is a rooted path, it rules. same goes
* if the second file specification is missing.
*/
if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/'))
{
merged = OPENSSL_strdup(filespec1);
if (merged == NULL)
{
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
return NULL;
}
}
else if (!filespec1)
{
merged = OPENSSL_strdup(filespec2);
if (merged == NULL)
{
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
return NULL;
}
} else
{
int spec2len, len;
spec2len = strlen(filespec2);
len = spec2len + strlen(filespec1);
if (spec2len && filespec2[spec2len - 1] == '/')
{
spec2len--;
len--;
}
merged = OPENSSL_malloc(len + 2);
if (merged == NULL)
{
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
return NULL;
}
strcpy(merged, filespec2);
merged[spec2len] = '/';
strcpy(&merged[spec2len + 1], filespec1);
}
return merged;
}
static char *dlfcn_name_converter(DSO *dso, const char *filename)
{
char *translated;
int len, rsize, transform;
len = strlen(filename);
rsize = len + 1;
transform = (strstr(filename, "/") == NULL);
if (transform) {
/* We will convert this to "%s.so" or "lib%s.so" etc */
rsize += strlen(DSO_EXTENSION); /* The length of ".so" */
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
rsize += 3; /* The length of "lib" */
}
rsize += 5;
translated = OPENSSL_malloc(rsize);
if (translated == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED);
return NULL;
}
if (transform) {
sprintf(translated, "%s.out", filename);
} else
sprintf(translated, "%s", filename);
return translated;
}
static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
{
return -1;
}
static void * dlfcn_globallookup(const char *name)
{
return NULL;
}
#else
# ifdef HAVE_DLFCN_H
# ifdef __osf__
# define __EXTENSIONS__
# endif
# include <dlfcn.h>
# define HAVE_DLINFO 1
# if defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
(defined(__osf__) && !defined(RTLD_NEXT)) || \
(defined(__OpenBSD__) && !defined(RTLD_SELF)) || \
defined(__ANDROID__) || defined(__TANDEM)
# undef HAVE_DLINFO
# endif
# endif
/*
* Prior to using the dlopen() function, we should decide on the flag we
* send. There's a few different ways of doing this and it's a messy
@@ -449,3 +878,5 @@ static void *dlfcn_globallookup(const char *name)
return ret;
}
#endif /* DSO_DLFCN */
#endif