diff options
| author | djm <> | 2008-09-06 12:15:54 +0000 |
|---|---|---|
| committer | djm <> | 2008-09-06 12:15:54 +0000 |
| commit | f1625f274acf5dcd5601f6cb5e29e233b2a441a3 (patch) | |
| tree | 44899ddfbef8f24aacbea50086c041c1b150f6d6 /src/lib/libcrypto/dso | |
| parent | 4f828b924f54507141fb95ebe49dfcd261945e85 (diff) | |
| download | openbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.tar.gz openbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.tar.bz2 openbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.zip | |
import of OpenSSL 0.9.8h
Diffstat (limited to 'src/lib/libcrypto/dso')
| -rw-r--r-- | src/lib/libcrypto/dso/Makefile | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dl.c | 102 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_vms.c | 137 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_win32.c | 364 |
4 files changed, 587 insertions, 62 deletions
diff --git a/src/lib/libcrypto/dso/Makefile b/src/lib/libcrypto/dso/Makefile index c16278c3ff..07f5d8d159 100644 --- a/src/lib/libcrypto/dso/Makefile +++ b/src/lib/libcrypto/dso/Makefile | |||
| @@ -7,11 +7,6 @@ TOP= ../.. | |||
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | 8 | INCLUDES= -I.. -I$(TOP) -I../../include |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKEDEPPROG= makedepend | ||
| 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 15 | MAKEFILE= Makefile | 10 | MAKEFILE= Makefile |
| 16 | AR= ar r | 11 | AR= ar r |
| 17 | 12 | ||
| @@ -53,6 +48,7 @@ links: | |||
| 53 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | 48 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) |
| 54 | 49 | ||
| 55 | install: | 50 | install: |
| 51 | @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... | ||
| 56 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | 52 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ |
| 57 | do \ | 53 | do \ |
| 58 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | 54 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ |
| @@ -68,6 +64,7 @@ lint: | |||
| 68 | lint -DLINT $(INCLUDES) $(SRC)>fluff | 64 | lint -DLINT $(INCLUDES) $(SRC)>fluff |
| 69 | 65 | ||
| 70 | depend: | 66 | depend: |
| 67 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
| 71 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | 68 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) |
| 72 | 69 | ||
| 73 | dclean: | 70 | dclean: |
| @@ -84,43 +81,47 @@ dso_dl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | |||
| 84 | dso_dl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 81 | dso_dl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 85 | dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 82 | dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 86 | dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 83 | dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 87 | dso_dl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 84 | dso_dl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h |
| 88 | dso_dl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_dl.c | 85 | dso_dl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 86 | dso_dl.o: ../cryptlib.h dso_dl.c | ||
| 89 | dso_dlfcn.o: ../../e_os.h ../../include/openssl/bio.h | 87 | dso_dlfcn.o: ../../e_os.h ../../include/openssl/bio.h |
| 90 | dso_dlfcn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 88 | dso_dlfcn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 91 | dso_dlfcn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 89 | dso_dlfcn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 92 | dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 90 | dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 93 | dso_dlfcn.o: ../../include/openssl/opensslconf.h | 91 | dso_dlfcn.o: ../../include/openssl/opensslconf.h |
| 94 | dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 92 | dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 95 | dso_dlfcn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 93 | dso_dlfcn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 96 | dso_dlfcn.o: ../cryptlib.h dso_dlfcn.c | 94 | dso_dlfcn.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_dlfcn.c |
| 97 | dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 95 | dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 98 | dso_err.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 96 | dso_err.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 99 | dso_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 97 | dso_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 100 | dso_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 98 | dso_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 101 | dso_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 99 | dso_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h |
| 102 | dso_err.o: ../../include/openssl/symhacks.h dso_err.c | 100 | dso_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 101 | dso_err.o: dso_err.c | ||
| 103 | dso_lib.o: ../../e_os.h ../../include/openssl/bio.h | 102 | dso_lib.o: ../../e_os.h ../../include/openssl/bio.h |
| 104 | dso_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 103 | dso_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 105 | dso_lib.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 104 | dso_lib.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 106 | dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 105 | dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 107 | dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 106 | dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 108 | dso_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 107 | dso_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h |
| 109 | dso_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_lib.c | 108 | dso_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 109 | dso_lib.o: ../cryptlib.h dso_lib.c | ||
| 110 | dso_null.o: ../../e_os.h ../../include/openssl/bio.h | 110 | dso_null.o: ../../e_os.h ../../include/openssl/bio.h |
| 111 | dso_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 111 | dso_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 112 | dso_null.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 112 | dso_null.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 113 | dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 113 | dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 114 | dso_null.o: ../../include/openssl/opensslconf.h | 114 | dso_null.o: ../../include/openssl/opensslconf.h |
| 115 | dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 115 | dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 116 | dso_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 116 | dso_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 117 | dso_null.o: ../cryptlib.h dso_null.c | 117 | dso_null.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_null.c |
| 118 | dso_openssl.o: ../../e_os.h ../../include/openssl/bio.h | 118 | dso_openssl.o: ../../e_os.h ../../include/openssl/bio.h |
| 119 | dso_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 119 | dso_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 120 | dso_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 120 | dso_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 121 | dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 121 | dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 122 | dso_openssl.o: ../../include/openssl/opensslconf.h | 122 | dso_openssl.o: ../../include/openssl/opensslconf.h |
| 123 | dso_openssl.o: ../../include/openssl/opensslv.h | 123 | dso_openssl.o: ../../include/openssl/opensslv.h |
| 124 | dso_openssl.o: ../../include/openssl/ossl_typ.h | ||
| 124 | dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 125 | dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 125 | dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_openssl.c | 126 | dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_openssl.c |
| 126 | dso_vms.o: ../../e_os.h ../../include/openssl/bio.h | 127 | dso_vms.o: ../../e_os.h ../../include/openssl/bio.h |
| @@ -128,13 +129,14 @@ dso_vms.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | |||
| 128 | dso_vms.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 129 | dso_vms.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 129 | dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 130 | dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 130 | dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 131 | dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 131 | dso_vms.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 132 | dso_vms.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h |
| 132 | dso_vms.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_vms.c | 133 | dso_vms.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 134 | dso_vms.o: ../cryptlib.h dso_vms.c | ||
| 133 | dso_win32.o: ../../e_os.h ../../include/openssl/bio.h | 135 | dso_win32.o: ../../e_os.h ../../include/openssl/bio.h |
| 134 | dso_win32.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 136 | dso_win32.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 135 | dso_win32.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | 137 | dso_win32.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h |
| 136 | dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 138 | dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 137 | dso_win32.o: ../../include/openssl/opensslconf.h | 139 | dso_win32.o: ../../include/openssl/opensslconf.h |
| 138 | dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 140 | dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 139 | dso_win32.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 141 | dso_win32.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 140 | dso_win32.o: ../cryptlib.h dso_win32.c | 142 | dso_win32.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_win32.c |
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c index f7b4dfc0c3..417abb6ea9 100644 --- a/src/lib/libcrypto/dso/dso_dl.c +++ b/src/lib/libcrypto/dso/dso_dl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* dso_dl.c */ | 1 | /* dso_dl.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -84,6 +84,7 @@ static int dl_finish(DSO *dso); | |||
| 84 | static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg); | 84 | static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 85 | #endif | 85 | #endif |
| 86 | static char *dl_name_converter(DSO *dso, const char *filename); | 86 | static char *dl_name_converter(DSO *dso, const char *filename); |
| 87 | static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2); | ||
| 87 | 88 | ||
| 88 | static DSO_METHOD dso_meth_dl = { | 89 | static DSO_METHOD dso_meth_dl = { |
| 89 | "OpenSSL 'dl' shared library method", | 90 | "OpenSSL 'dl' shared library method", |
| @@ -98,6 +99,7 @@ static DSO_METHOD dso_meth_dl = { | |||
| 98 | #endif | 99 | #endif |
| 99 | NULL, /* ctrl */ | 100 | NULL, /* ctrl */ |
| 100 | dl_name_converter, | 101 | dl_name_converter, |
| 102 | dl_merger, | ||
| 101 | NULL, /* init */ | 103 | NULL, /* init */ |
| 102 | NULL /* finish */ | 104 | NULL /* finish */ |
| 103 | }; | 105 | }; |
| @@ -239,6 +241,72 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname) | |||
| 239 | return((DSO_FUNC_TYPE)sym); | 241 | return((DSO_FUNC_TYPE)sym); |
| 240 | } | 242 | } |
| 241 | 243 | ||
| 244 | static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) | ||
| 245 | { | ||
| 246 | char *merged; | ||
| 247 | |||
| 248 | if(!filespec1 && !filespec2) | ||
| 249 | { | ||
| 250 | DSOerr(DSO_F_DL_MERGER, | ||
| 251 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 252 | return(NULL); | ||
| 253 | } | ||
| 254 | /* If the first file specification is a rooted path, it rules. | ||
| 255 | same goes if the second file specification is missing. */ | ||
| 256 | if (!filespec2 || filespec1[0] == '/') | ||
| 257 | { | ||
| 258 | merged = OPENSSL_malloc(strlen(filespec1) + 1); | ||
| 259 | if(!merged) | ||
| 260 | { | ||
| 261 | DSOerr(DSO_F_DL_MERGER, | ||
| 262 | ERR_R_MALLOC_FAILURE); | ||
| 263 | return(NULL); | ||
| 264 | } | ||
| 265 | strcpy(merged, filespec1); | ||
| 266 | } | ||
| 267 | /* If the first file specification is missing, the second one rules. */ | ||
| 268 | else if (!filespec1) | ||
| 269 | { | ||
| 270 | merged = OPENSSL_malloc(strlen(filespec2) + 1); | ||
| 271 | if(!merged) | ||
| 272 | { | ||
| 273 | DSOerr(DSO_F_DL_MERGER, | ||
| 274 | ERR_R_MALLOC_FAILURE); | ||
| 275 | return(NULL); | ||
| 276 | } | ||
| 277 | strcpy(merged, filespec2); | ||
| 278 | } | ||
| 279 | else | ||
| 280 | /* This part isn't as trivial as it looks. It assumes that | ||
| 281 | the second file specification really is a directory, and | ||
| 282 | makes no checks whatsoever. Therefore, the result becomes | ||
| 283 | the concatenation of filespec2 followed by a slash followed | ||
| 284 | by filespec1. */ | ||
| 285 | { | ||
| 286 | int spec2len, len; | ||
| 287 | |||
| 288 | spec2len = (filespec2 ? strlen(filespec2) : 0); | ||
| 289 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); | ||
| 290 | |||
| 291 | if(filespec2 && filespec2[spec2len - 1] == '/') | ||
| 292 | { | ||
| 293 | spec2len--; | ||
| 294 | len--; | ||
| 295 | } | ||
| 296 | merged = OPENSSL_malloc(len + 2); | ||
| 297 | if(!merged) | ||
| 298 | { | ||
| 299 | DSOerr(DSO_F_DL_MERGER, | ||
| 300 | ERR_R_MALLOC_FAILURE); | ||
| 301 | return(NULL); | ||
| 302 | } | ||
| 303 | strcpy(merged, filespec2); | ||
| 304 | merged[spec2len] = '/'; | ||
| 305 | strcpy(&merged[spec2len + 1], filespec1); | ||
| 306 | } | ||
| 307 | return(merged); | ||
| 308 | } | ||
| 309 | |||
| 242 | /* This function is identical to the one in dso_dlfcn.c, but as it is highly | 310 | /* This function is identical to the one in dso_dlfcn.c, but as it is highly |
| 243 | * unlikely that both the "dl" *and* "dlfcn" variants are being compiled at the | 311 | * unlikely that both the "dl" *and* "dlfcn" variants are being compiled at the |
| 244 | * same time, there's no great duplicating the code. Figuring out an elegant | 312 | * same time, there's no great duplicating the code. Figuring out an elegant |
| @@ -282,36 +350,4 @@ static char *dl_name_converter(DSO *dso, const char *filename) | |||
| 282 | return(translated); | 350 | return(translated); |
| 283 | } | 351 | } |
| 284 | 352 | ||
| 285 | #ifdef OPENSSL_FIPS | ||
| 286 | static void dl_ref_point(){} | ||
| 287 | |||
| 288 | int DSO_pathbyaddr(void *addr,char *path,int sz) | ||
| 289 | { | ||
| 290 | struct shl_descriptor inf; | ||
| 291 | int i,len; | ||
| 292 | |||
| 293 | if (addr == NULL) | ||
| 294 | { | ||
| 295 | union { void(*f)(); void *p; } t = { dl_ref_point }; | ||
| 296 | addr = t.p; | ||
| 297 | } | ||
| 298 | |||
| 299 | for (i=-1;shl_get_r(i,&inf)==0;i++) | ||
| 300 | { | ||
| 301 | if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) || | ||
| 302 | ((size_t)addr >= inf.dstart && (size_t)addr < inf.dend)) | ||
| 303 | { | ||
| 304 | len = (int)strlen(inf.filename); | ||
| 305 | if (sz <= 0) return len+1; | ||
| 306 | if (len >= sz) len=sz-1; | ||
| 307 | memcpy(path,inf.filename,len); | ||
| 308 | path[len++] = 0; | ||
| 309 | return len; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | |||
| 313 | return -1; | ||
| 314 | } | ||
| 315 | #endif | ||
| 316 | |||
| 317 | #endif /* DSO_DL */ | 353 | #endif /* DSO_DL */ |
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c index 1674619d17..2c434ee8a6 100644 --- a/src/lib/libcrypto/dso/dso_vms.c +++ b/src/lib/libcrypto/dso/dso_vms.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* dso_vms.c */ | 1 | /* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -63,6 +63,7 @@ | |||
| 63 | #include <openssl/dso.h> | 63 | #include <openssl/dso.h> |
| 64 | #ifdef OPENSSL_SYS_VMS | 64 | #ifdef OPENSSL_SYS_VMS |
| 65 | #pragma message disable DOLLARID | 65 | #pragma message disable DOLLARID |
| 66 | #include <rms.h> | ||
| 66 | #include <lib$routines.h> | 67 | #include <lib$routines.h> |
| 67 | #include <stsdef.h> | 68 | #include <stsdef.h> |
| 68 | #include <descrip.h> | 69 | #include <descrip.h> |
| @@ -89,6 +90,8 @@ static int vms_finish(DSO *dso); | |||
| 89 | static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg); | 90 | static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 90 | #endif | 91 | #endif |
| 91 | static char *vms_name_converter(DSO *dso, const char *filename); | 92 | static char *vms_name_converter(DSO *dso, const char *filename); |
| 93 | static char *vms_merger(DSO *dso, const char *filespec1, | ||
| 94 | const char *filespec2); | ||
| 92 | 95 | ||
| 93 | static DSO_METHOD dso_meth_vms = { | 96 | static DSO_METHOD dso_meth_vms = { |
| 94 | "OpenSSL 'VMS' shared library method", | 97 | "OpenSSL 'VMS' shared library method", |
| @@ -103,6 +106,7 @@ static DSO_METHOD dso_meth_vms = { | |||
| 103 | #endif | 106 | #endif |
| 104 | NULL, /* ctrl */ | 107 | NULL, /* ctrl */ |
| 105 | vms_name_converter, | 108 | vms_name_converter, |
| 109 | vms_merger, | ||
| 106 | NULL, /* init */ | 110 | NULL, /* init */ |
| 107 | NULL /* finish */ | 111 | NULL /* finish */ |
| 108 | }; | 112 | }; |
| @@ -140,7 +144,7 @@ static int vms_load(DSO *dso) | |||
| 140 | 144 | ||
| 141 | if(filename == NULL) | 145 | if(filename == NULL) |
| 142 | { | 146 | { |
| 143 | DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME); | 147 | DSOerr(DSO_F_VMS_LOAD,DSO_R_NO_FILENAME); |
| 144 | goto err; | 148 | goto err; |
| 145 | } | 149 | } |
| 146 | 150 | ||
| @@ -295,19 +299,19 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) | |||
| 295 | 299 | ||
| 296 | if((dso == NULL) || (symname == NULL)) | 300 | if((dso == NULL) || (symname == NULL)) |
| 297 | { | 301 | { |
| 298 | DSOerr(DSO_F_VMS_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); | 302 | DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER); |
| 299 | return; | 303 | return; |
| 300 | } | 304 | } |
| 301 | if(sk_num(dso->meth_data) < 1) | 305 | if(sk_num(dso->meth_data) < 1) |
| 302 | { | 306 | { |
| 303 | DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_STACK_ERROR); | 307 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR); |
| 304 | return; | 308 | return; |
| 305 | } | 309 | } |
| 306 | ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data, | 310 | ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data, |
| 307 | sk_num(dso->meth_data) - 1); | 311 | sk_num(dso->meth_data) - 1); |
| 308 | if(ptr == NULL) | 312 | if(ptr == NULL) |
| 309 | { | 313 | { |
| 310 | DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_NULL_HANDLE); | 314 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE); |
| 311 | return; | 315 | return; |
| 312 | } | 316 | } |
| 313 | 317 | ||
| @@ -336,7 +340,7 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) | |||
| 336 | { | 340 | { |
| 337 | errstring[length] = '\0'; | 341 | errstring[length] = '\0'; |
| 338 | 342 | ||
| 339 | DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_SYM_FAILURE); | 343 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_SYM_FAILURE); |
| 340 | if (ptr->imagename_dsc.dsc$w_length) | 344 | if (ptr->imagename_dsc.dsc$w_length) |
| 341 | ERR_add_error_data(9, | 345 | ERR_add_error_data(9, |
| 342 | "Symbol ", symname, | 346 | "Symbol ", symname, |
| @@ -368,6 +372,127 @@ static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname) | |||
| 368 | return sym; | 372 | return sym; |
| 369 | } | 373 | } |
| 370 | 374 | ||
| 375 | static char *vms_merger(DSO *dso, const char *filespec1, const char *filespec2) | ||
| 376 | { | ||
| 377 | int status; | ||
| 378 | int filespec1len, filespec2len; | ||
| 379 | struct FAB fab; | ||
| 380 | #ifdef NAML$C_MAXRSS | ||
| 381 | struct NAML nam; | ||
| 382 | char esa[NAML$C_MAXRSS]; | ||
| 383 | #else | ||
| 384 | struct NAM nam; | ||
| 385 | char esa[NAM$C_MAXRSS]; | ||
| 386 | #endif | ||
| 387 | char *merged; | ||
| 388 | |||
| 389 | if (!filespec1) filespec1 = ""; | ||
| 390 | if (!filespec2) filespec2 = ""; | ||
| 391 | filespec1len = strlen(filespec1); | ||
| 392 | filespec2len = strlen(filespec2); | ||
| 393 | |||
| 394 | fab = cc$rms_fab; | ||
| 395 | #ifdef NAML$C_MAXRSS | ||
| 396 | nam = cc$rms_naml; | ||
| 397 | #else | ||
| 398 | nam = cc$rms_nam; | ||
| 399 | #endif | ||
| 400 | |||
| 401 | fab.fab$l_fna = (char *)filespec1; | ||
| 402 | fab.fab$b_fns = filespec1len; | ||
| 403 | fab.fab$l_dna = (char *)filespec2; | ||
| 404 | fab.fab$b_dns = filespec2len; | ||
| 405 | #ifdef NAML$C_MAXRSS | ||
| 406 | if (filespec1len > NAM$C_MAXRSS) | ||
| 407 | { | ||
| 408 | fab.fab$l_fna = 0; | ||
| 409 | fab.fab$b_fns = 0; | ||
| 410 | nam.naml$l_long_filename = (char *)filespec1; | ||
| 411 | nam.naml$l_long_filename_size = filespec1len; | ||
| 412 | } | ||
| 413 | if (filespec2len > NAM$C_MAXRSS) | ||
| 414 | { | ||
| 415 | fab.fab$l_dna = 0; | ||
| 416 | fab.fab$b_dns = 0; | ||
| 417 | nam.naml$l_long_defname = (char *)filespec2; | ||
| 418 | nam.naml$l_long_defname_size = filespec2len; | ||
| 419 | } | ||
| 420 | nam.naml$l_esa = esa; | ||
| 421 | nam.naml$b_ess = NAM$C_MAXRSS; | ||
| 422 | nam.naml$l_long_expand = esa; | ||
| 423 | nam.naml$l_long_expand_alloc = sizeof(esa); | ||
| 424 | nam.naml$b_nop = NAM$M_SYNCHK | NAM$M_PWD; | ||
| 425 | nam.naml$v_no_short_upcase = 1; | ||
| 426 | fab.fab$l_naml = &nam; | ||
| 427 | #else | ||
| 428 | nam.nam$l_esa = esa; | ||
| 429 | nam.nam$b_ess = NAM$C_MAXRSS; | ||
| 430 | nam.nam$b_nop = NAM$M_SYNCHK | NAM$M_PWD; | ||
| 431 | fab.fab$l_nam = &nam; | ||
| 432 | #endif | ||
| 433 | |||
| 434 | status = sys$parse(&fab, 0, 0); | ||
| 435 | |||
| 436 | if(!$VMS_STATUS_SUCCESS(status)) | ||
| 437 | { | ||
| 438 | unsigned short length; | ||
| 439 | char errstring[257]; | ||
| 440 | struct dsc$descriptor_s errstring_dsc; | ||
| 441 | |||
| 442 | errstring_dsc.dsc$w_length = sizeof(errstring); | ||
| 443 | errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | ||
| 444 | errstring_dsc.dsc$b_class = DSC$K_CLASS_S; | ||
| 445 | errstring_dsc.dsc$a_pointer = errstring; | ||
| 446 | |||
| 447 | status = sys$getmsg(status, &length, &errstring_dsc, 1, 0); | ||
| 448 | |||
| 449 | if (!$VMS_STATUS_SUCCESS(status)) | ||
| 450 | lib$signal(status); /* This is really bad. Abort! */ | ||
| 451 | else | ||
| 452 | { | ||
| 453 | errstring[length] = '\0'; | ||
| 454 | |||
| 455 | DSOerr(DSO_F_VMS_MERGER,DSO_R_FAILURE); | ||
| 456 | ERR_add_error_data(7, | ||
| 457 | "filespec \"", filespec1, "\", ", | ||
| 458 | "defaults \"", filespec2, "\": ", | ||
| 459 | errstring); | ||
| 460 | } | ||
| 461 | return(NULL); | ||
| 462 | } | ||
| 463 | #ifdef NAML$C_MAXRSS | ||
| 464 | if (nam.naml$l_long_expand_size) | ||
| 465 | { | ||
| 466 | merged = OPENSSL_malloc(nam.naml$l_long_expand_size + 1); | ||
| 467 | if(!merged) | ||
| 468 | goto malloc_err; | ||
| 469 | strncpy(merged, nam.naml$l_long_expand, | ||
| 470 | nam.naml$l_long_expand_size); | ||
| 471 | merged[nam.naml$l_long_expand_size] = '\0'; | ||
| 472 | } | ||
| 473 | else | ||
| 474 | { | ||
| 475 | merged = OPENSSL_malloc(nam.naml$b_esl + 1); | ||
| 476 | if(!merged) | ||
| 477 | goto malloc_err; | ||
| 478 | strncpy(merged, nam.naml$l_esa, | ||
| 479 | nam.naml$b_esl); | ||
| 480 | merged[nam.naml$b_esl] = '\0'; | ||
| 481 | } | ||
| 482 | #else | ||
| 483 | merged = OPENSSL_malloc(nam.nam$b_esl + 1); | ||
| 484 | if(!merged) | ||
| 485 | goto malloc_err; | ||
| 486 | strncpy(merged, nam.nam$l_esa, | ||
| 487 | nam.nam$b_esl); | ||
| 488 | merged[nam.nam$b_esl] = '\0'; | ||
| 489 | #endif | ||
| 490 | return(merged); | ||
| 491 | malloc_err: | ||
| 492 | DSOerr(DSO_F_VMS_MERGER, | ||
| 493 | ERR_R_MALLOC_FAILURE); | ||
| 494 | } | ||
| 495 | |||
| 371 | static char *vms_name_converter(DSO *dso, const char *filename) | 496 | static char *vms_name_converter(DSO *dso, const char *filename) |
| 372 | { | 497 | { |
| 373 | int len = strlen(filename); | 498 | int len = strlen(filename); |
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c index cc4ac68696..fd3dd6a7fe 100644 --- a/src/lib/libcrypto/dso/dso_win32.c +++ b/src/lib/libcrypto/dso/dso_win32.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* dso_win32.c */ | 1 | /* dso_win32.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -85,6 +85,26 @@ static FARPROC GetProcAddressA(HMODULE hModule,LPCSTR lpProcName) | |||
| 85 | # endif | 85 | # endif |
| 86 | # undef GetProcAddress | 86 | # undef GetProcAddress |
| 87 | # define GetProcAddress GetProcAddressA | 87 | # define GetProcAddress GetProcAddressA |
| 88 | |||
| 89 | static HINSTANCE LoadLibraryA(LPCSTR lpLibFileName) | ||
| 90 | { | ||
| 91 | WCHAR *fnamw; | ||
| 92 | size_t len_0=strlen(lpLibFileName)+1,i; | ||
| 93 | |||
| 94 | #ifdef _MSC_VER | ||
| 95 | fnamw = (WCHAR *)_alloca (len_0*sizeof(WCHAR)); | ||
| 96 | #else | ||
| 97 | fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR)); | ||
| 98 | #endif | ||
| 99 | if (fnamw == NULL) return NULL; | ||
| 100 | |||
| 101 | #if defined(_WIN32_WCE) && _WIN32_WCE>=101 | ||
| 102 | if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0)) | ||
| 103 | #endif | ||
| 104 | for (i=0;i<len_0;i++) fnamw[i]=(WCHAR)lpLibFileName[i]; | ||
| 105 | |||
| 106 | return LoadLibraryW(fnamw); | ||
| 107 | } | ||
| 88 | #endif | 108 | #endif |
| 89 | 109 | ||
| 90 | /* Part of the hack in "win32_load" ... */ | 110 | /* Part of the hack in "win32_load" ... */ |
| @@ -102,6 +122,10 @@ static int win32_finish(DSO *dso); | |||
| 102 | static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); | 122 | static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 103 | #endif | 123 | #endif |
| 104 | static char *win32_name_converter(DSO *dso, const char *filename); | 124 | static char *win32_name_converter(DSO *dso, const char *filename); |
| 125 | static char *win32_merger(DSO *dso, const char *filespec1, | ||
| 126 | const char *filespec2); | ||
| 127 | |||
| 128 | static const char *openssl_strnchr(const char *string, int c, size_t len); | ||
| 105 | 129 | ||
| 106 | static DSO_METHOD dso_meth_win32 = { | 130 | static DSO_METHOD dso_meth_win32 = { |
| 107 | "OpenSSL 'win32' shared library method", | 131 | "OpenSSL 'win32' shared library method", |
| @@ -116,6 +140,7 @@ static DSO_METHOD dso_meth_win32 = { | |||
| 116 | #endif | 140 | #endif |
| 117 | NULL, /* ctrl */ | 141 | NULL, /* ctrl */ |
| 118 | win32_name_converter, | 142 | win32_name_converter, |
| 143 | win32_merger, | ||
| 119 | NULL, /* init */ | 144 | NULL, /* init */ |
| 120 | NULL /* finish */ | 145 | NULL /* finish */ |
| 121 | }; | 146 | }; |
| @@ -267,6 +292,330 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname) | |||
| 267 | return((DSO_FUNC_TYPE)sym); | 292 | return((DSO_FUNC_TYPE)sym); |
| 268 | } | 293 | } |
| 269 | 294 | ||
| 295 | struct file_st | ||
| 296 | { | ||
| 297 | const char *node; int nodelen; | ||
| 298 | const char *device; int devicelen; | ||
| 299 | const char *predir; int predirlen; | ||
| 300 | const char *dir; int dirlen; | ||
| 301 | const char *file; int filelen; | ||
| 302 | }; | ||
| 303 | |||
| 304 | static struct file_st *win32_splitter(DSO *dso, const char *filename, | ||
| 305 | int assume_last_is_dir) | ||
| 306 | { | ||
| 307 | struct file_st *result = NULL; | ||
| 308 | enum { IN_NODE, IN_DEVICE, IN_FILE } position; | ||
| 309 | const char *start = filename; | ||
| 310 | char last; | ||
| 311 | |||
| 312 | if (!filename) | ||
| 313 | { | ||
| 314 | DSOerr(DSO_F_WIN32_SPLITTER,DSO_R_NO_FILENAME); | ||
| 315 | /*goto err;*/ | ||
| 316 | return(NULL); | ||
| 317 | } | ||
| 318 | |||
| 319 | result = OPENSSL_malloc(sizeof(struct file_st)); | ||
| 320 | if(result == NULL) | ||
| 321 | { | ||
| 322 | DSOerr(DSO_F_WIN32_SPLITTER, | ||
| 323 | ERR_R_MALLOC_FAILURE); | ||
| 324 | return(NULL); | ||
| 325 | } | ||
| 326 | |||
| 327 | memset(result, 0, sizeof(struct file_st)); | ||
| 328 | position = IN_DEVICE; | ||
| 329 | |||
| 330 | if(filename[0] == '\\' && filename[1] == '\\' | ||
| 331 | || filename[0] == '/' && filename[1] == '/') | ||
| 332 | { | ||
| 333 | position = IN_NODE; | ||
| 334 | filename += 2; | ||
| 335 | start = filename; | ||
| 336 | result->node = start; | ||
| 337 | } | ||
| 338 | |||
| 339 | do | ||
| 340 | { | ||
| 341 | last = filename[0]; | ||
| 342 | switch(last) | ||
| 343 | { | ||
| 344 | case ':': | ||
| 345 | if(position != IN_DEVICE) | ||
| 346 | { | ||
| 347 | DSOerr(DSO_F_WIN32_SPLITTER, | ||
| 348 | DSO_R_INCORRECT_FILE_SYNTAX); | ||
| 349 | /*goto err;*/ | ||
| 350 | return(NULL); | ||
| 351 | } | ||
| 352 | result->device = start; | ||
| 353 | result->devicelen = filename - start; | ||
| 354 | position = IN_FILE; | ||
| 355 | start = ++filename; | ||
| 356 | result->dir = start; | ||
| 357 | break; | ||
| 358 | case '\\': | ||
| 359 | case '/': | ||
| 360 | if(position == IN_NODE) | ||
| 361 | { | ||
| 362 | result->nodelen = filename - start; | ||
| 363 | position = IN_FILE; | ||
| 364 | start = ++filename; | ||
| 365 | result->dir = start; | ||
| 366 | } | ||
| 367 | else if(position == IN_DEVICE) | ||
| 368 | { | ||
| 369 | position = IN_FILE; | ||
| 370 | filename++; | ||
| 371 | result->dir = start; | ||
| 372 | result->dirlen = filename - start; | ||
| 373 | start = filename; | ||
| 374 | } | ||
| 375 | else | ||
| 376 | { | ||
| 377 | filename++; | ||
| 378 | result->dirlen += filename - start; | ||
| 379 | start = filename; | ||
| 380 | } | ||
| 381 | break; | ||
| 382 | case '\0': | ||
| 383 | if(position == IN_NODE) | ||
| 384 | { | ||
| 385 | result->nodelen = filename - start; | ||
| 386 | } | ||
| 387 | else | ||
| 388 | { | ||
| 389 | if(filename - start > 0) | ||
| 390 | { | ||
| 391 | if (assume_last_is_dir) | ||
| 392 | { | ||
| 393 | if (position == IN_DEVICE) | ||
| 394 | { | ||
| 395 | result->dir = start; | ||
| 396 | result->dirlen = 0; | ||
| 397 | } | ||
| 398 | result->dirlen += | ||
| 399 | filename - start; | ||
| 400 | } | ||
| 401 | else | ||
| 402 | { | ||
| 403 | result->file = start; | ||
| 404 | result->filelen = | ||
| 405 | filename - start; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | } | ||
| 409 | break; | ||
| 410 | default: | ||
| 411 | filename++; | ||
| 412 | break; | ||
| 413 | } | ||
| 414 | } | ||
| 415 | while(last); | ||
| 416 | |||
| 417 | if(!result->nodelen) result->node = NULL; | ||
| 418 | if(!result->devicelen) result->device = NULL; | ||
| 419 | if(!result->dirlen) result->dir = NULL; | ||
| 420 | if(!result->filelen) result->file = NULL; | ||
| 421 | |||
| 422 | return(result); | ||
| 423 | } | ||
| 424 | |||
| 425 | static char *win32_joiner(DSO *dso, const struct file_st *file_split) | ||
| 426 | { | ||
| 427 | int len = 0, offset = 0; | ||
| 428 | char *result = NULL; | ||
| 429 | const char *start; | ||
| 430 | |||
| 431 | if(!file_split) | ||
| 432 | { | ||
| 433 | DSOerr(DSO_F_WIN32_JOINER, | ||
| 434 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 435 | return(NULL); | ||
| 436 | } | ||
| 437 | if(file_split->node) | ||
| 438 | { | ||
| 439 | len += 2 + file_split->nodelen; /* 2 for starting \\ */ | ||
| 440 | if(file_split->predir || file_split->dir || file_split->file) | ||
| 441 | len++; /* 1 for ending \ */ | ||
| 442 | } | ||
| 443 | else if(file_split->device) | ||
| 444 | { | ||
| 445 | len += file_split->devicelen + 1; /* 1 for ending : */ | ||
| 446 | } | ||
| 447 | len += file_split->predirlen; | ||
| 448 | if(file_split->predir && (file_split->dir || file_split->file)) | ||
| 449 | { | ||
| 450 | len++; /* 1 for ending \ */ | ||
| 451 | } | ||
| 452 | len += file_split->dirlen; | ||
| 453 | if(file_split->dir && file_split->file) | ||
| 454 | { | ||
| 455 | len++; /* 1 for ending \ */ | ||
| 456 | } | ||
| 457 | len += file_split->filelen; | ||
| 458 | |||
| 459 | if(!len) | ||
| 460 | { | ||
| 461 | DSOerr(DSO_F_WIN32_JOINER, DSO_R_EMPTY_FILE_STRUCTURE); | ||
| 462 | return(NULL); | ||
| 463 | } | ||
| 464 | |||
| 465 | result = OPENSSL_malloc(len + 1); | ||
| 466 | if (!result) | ||
| 467 | { | ||
| 468 | DSOerr(DSO_F_WIN32_JOINER, | ||
| 469 | ERR_R_MALLOC_FAILURE); | ||
| 470 | return(NULL); | ||
| 471 | } | ||
| 472 | |||
| 473 | if(file_split->node) | ||
| 474 | { | ||
| 475 | strcpy(&result[offset], "\\\\"); offset += 2; | ||
| 476 | strncpy(&result[offset], file_split->node, | ||
| 477 | file_split->nodelen); offset += file_split->nodelen; | ||
| 478 | if(file_split->predir || file_split->dir || file_split->file) | ||
| 479 | { | ||
| 480 | result[offset] = '\\'; offset++; | ||
| 481 | } | ||
| 482 | } | ||
| 483 | else if(file_split->device) | ||
| 484 | { | ||
| 485 | strncpy(&result[offset], file_split->device, | ||
| 486 | file_split->devicelen); offset += file_split->devicelen; | ||
| 487 | result[offset] = ':'; offset++; | ||
| 488 | } | ||
| 489 | start = file_split->predir; | ||
| 490 | while(file_split->predirlen > (start - file_split->predir)) | ||
| 491 | { | ||
| 492 | const char *end = openssl_strnchr(start, '/', | ||
| 493 | file_split->predirlen - (start - file_split->predir)); | ||
| 494 | if(!end) | ||
| 495 | end = start | ||
| 496 | + file_split->predirlen | ||
| 497 | - (start - file_split->predir); | ||
| 498 | strncpy(&result[offset], start, | ||
| 499 | end - start); offset += end - start; | ||
| 500 | result[offset] = '\\'; offset++; | ||
| 501 | start = end + 1; | ||
| 502 | } | ||
| 503 | #if 0 /* Not needed, since the directory converter above already appeneded | ||
| 504 | a backslash */ | ||
| 505 | if(file_split->predir && (file_split->dir || file_split->file)) | ||
| 506 | { | ||
| 507 | result[offset] = '\\'; offset++; | ||
| 508 | } | ||
| 509 | #endif | ||
| 510 | start = file_split->dir; | ||
| 511 | while(file_split->dirlen > (start - file_split->dir)) | ||
| 512 | { | ||
| 513 | const char *end = openssl_strnchr(start, '/', | ||
| 514 | file_split->dirlen - (start - file_split->dir)); | ||
| 515 | if(!end) | ||
| 516 | end = start | ||
| 517 | + file_split->dirlen | ||
| 518 | - (start - file_split->dir); | ||
| 519 | strncpy(&result[offset], start, | ||
| 520 | end - start); offset += end - start; | ||
| 521 | result[offset] = '\\'; offset++; | ||
| 522 | start = end + 1; | ||
| 523 | } | ||
| 524 | #if 0 /* Not needed, since the directory converter above already appeneded | ||
| 525 | a backslash */ | ||
| 526 | if(file_split->dir && file_split->file) | ||
| 527 | { | ||
| 528 | result[offset] = '\\'; offset++; | ||
| 529 | } | ||
| 530 | #endif | ||
| 531 | strncpy(&result[offset], file_split->file, | ||
| 532 | file_split->filelen); offset += file_split->filelen; | ||
| 533 | result[offset] = '\0'; | ||
| 534 | return(result); | ||
| 535 | } | ||
| 536 | |||
| 537 | static char *win32_merger(DSO *dso, const char *filespec1, const char *filespec2) | ||
| 538 | { | ||
| 539 | char *merged = NULL; | ||
| 540 | struct file_st *filespec1_split = NULL; | ||
| 541 | struct file_st *filespec2_split = NULL; | ||
| 542 | |||
| 543 | if(!filespec1 && !filespec2) | ||
| 544 | { | ||
| 545 | DSOerr(DSO_F_WIN32_MERGER, | ||
| 546 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 547 | return(NULL); | ||
| 548 | } | ||
| 549 | if (!filespec2) | ||
| 550 | { | ||
| 551 | merged = OPENSSL_malloc(strlen(filespec1) + 1); | ||
| 552 | if(!merged) | ||
| 553 | { | ||
| 554 | DSOerr(DSO_F_WIN32_MERGER, | ||
| 555 | ERR_R_MALLOC_FAILURE); | ||
| 556 | return(NULL); | ||
| 557 | } | ||
| 558 | strcpy(merged, filespec1); | ||
| 559 | } | ||
| 560 | else if (!filespec1) | ||
| 561 | { | ||
| 562 | merged = OPENSSL_malloc(strlen(filespec2) + 1); | ||
| 563 | if(!merged) | ||
| 564 | { | ||
| 565 | DSOerr(DSO_F_WIN32_MERGER, | ||
| 566 | ERR_R_MALLOC_FAILURE); | ||
| 567 | return(NULL); | ||
| 568 | } | ||
| 569 | strcpy(merged, filespec2); | ||
| 570 | } | ||
| 571 | else | ||
| 572 | { | ||
| 573 | filespec1_split = win32_splitter(dso, filespec1, 0); | ||
| 574 | if (!filespec1_split) | ||
| 575 | { | ||
| 576 | DSOerr(DSO_F_WIN32_MERGER, | ||
| 577 | ERR_R_MALLOC_FAILURE); | ||
| 578 | return(NULL); | ||
| 579 | } | ||
| 580 | filespec2_split = win32_splitter(dso, filespec2, 1); | ||
| 581 | if (!filespec2_split) | ||
| 582 | { | ||
| 583 | DSOerr(DSO_F_WIN32_MERGER, | ||
| 584 | ERR_R_MALLOC_FAILURE); | ||
| 585 | OPENSSL_free(filespec1_split); | ||
| 586 | return(NULL); | ||
| 587 | } | ||
| 588 | |||
| 589 | /* Fill in into filespec1_split */ | ||
| 590 | if (!filespec1_split->node && !filespec1_split->device) | ||
| 591 | { | ||
| 592 | filespec1_split->node = filespec2_split->node; | ||
| 593 | filespec1_split->nodelen = filespec2_split->nodelen; | ||
| 594 | filespec1_split->device = filespec2_split->device; | ||
| 595 | filespec1_split->devicelen = filespec2_split->devicelen; | ||
| 596 | } | ||
| 597 | if (!filespec1_split->dir) | ||
| 598 | { | ||
| 599 | filespec1_split->dir = filespec2_split->dir; | ||
| 600 | filespec1_split->dirlen = filespec2_split->dirlen; | ||
| 601 | } | ||
| 602 | else if (filespec1_split->dir[0] != '\\' | ||
| 603 | && filespec1_split->dir[0] != '/') | ||
| 604 | { | ||
| 605 | filespec1_split->predir = filespec2_split->dir; | ||
| 606 | filespec1_split->predirlen = filespec2_split->dirlen; | ||
| 607 | } | ||
| 608 | if (!filespec1_split->file) | ||
| 609 | { | ||
| 610 | filespec1_split->file = filespec2_split->file; | ||
| 611 | filespec1_split->filelen = filespec2_split->filelen; | ||
| 612 | } | ||
| 613 | |||
| 614 | merged = win32_joiner(dso, filespec1_split); | ||
| 615 | } | ||
| 616 | return(merged); | ||
| 617 | } | ||
| 618 | |||
| 270 | static char *win32_name_converter(DSO *dso, const char *filename) | 619 | static char *win32_name_converter(DSO *dso, const char *filename) |
| 271 | { | 620 | { |
| 272 | char *translated; | 621 | char *translated; |
| @@ -295,4 +644,17 @@ static char *win32_name_converter(DSO *dso, const char *filename) | |||
| 295 | return(translated); | 644 | return(translated); |
| 296 | } | 645 | } |
| 297 | 646 | ||
| 647 | static const char *openssl_strnchr(const char *string, int c, size_t len) | ||
| 648 | { | ||
| 649 | size_t i; | ||
| 650 | const char *p; | ||
| 651 | for (i = 0, p = string; i < len && *p; i++, p++) | ||
| 652 | { | ||
| 653 | if (*p == c) | ||
| 654 | return p; | ||
| 655 | } | ||
| 656 | return NULL; | ||
| 657 | } | ||
| 658 | |||
| 659 | |||
| 298 | #endif /* OPENSSL_SYS_WIN32 */ | 660 | #endif /* OPENSSL_SYS_WIN32 */ |
