diff options
| author | djm <> | 2008-09-06 12:17:54 +0000 |
|---|---|---|
| committer | djm <> | 2008-09-06 12:17:54 +0000 |
| commit | 6b62d1fdd8a4fd35acfcc0c4bb1bf8b757fa8cda (patch) | |
| tree | 7ccc28afe1789ea3dbedf72365f955d5b8e105b5 /src/lib/libcrypto/bio | |
| parent | 89181603212b41e95cde36b1be5a146ce8fb2935 (diff) | |
| download | openbsd-6b62d1fdd8a4fd35acfcc0c4bb1bf8b757fa8cda.tar.gz openbsd-6b62d1fdd8a4fd35acfcc0c4bb1bf8b757fa8cda.tar.bz2 openbsd-6b62d1fdd8a4fd35acfcc0c4bb1bf8b757fa8cda.zip | |
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 75 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_print.c | 20 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 60 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_nbio.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio.h | 133 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_err.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 60 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_acpt.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_conn.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_fd.c | 30 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 109 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_sock.c | 7 |
13 files changed, 406 insertions, 118 deletions
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index f671e722fa..c80ecc4295 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c | |||
| @@ -62,30 +62,32 @@ | |||
| 62 | 62 | ||
| 63 | #include <stdio.h> | 63 | #include <stdio.h> |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | #include <openssl/bio.h> | 65 | #include "bio_lcl.h" |
| 66 | 66 | ||
| 67 | #define TRUNCATE | 67 | #define TRUNCATE |
| 68 | #define DUMP_WIDTH 16 | 68 | #define DUMP_WIDTH 16 |
| 69 | #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4)) | 69 | #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4)) |
| 70 | 70 | ||
| 71 | int BIO_dump(BIO *bio, const char *s, int len) | 71 | int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), |
| 72 | void *u, const char *s, int len) | ||
| 72 | { | 73 | { |
| 73 | return BIO_dump_indent(bio, s, len, 0); | 74 | return BIO_dump_indent_cb(cb, u, s, len, 0); |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) | 77 | int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), |
| 78 | void *u, const char *s, int len, int indent) | ||
| 77 | { | 79 | { |
| 78 | int ret=0; | 80 | int ret=0; |
| 79 | char buf[288+1],tmp[20],str[128+1]; | 81 | char buf[288+1],tmp[20],str[128+1]; |
| 80 | int i,j,rows,trunc; | 82 | int i,j,rows,trc; |
| 81 | unsigned char ch; | 83 | unsigned char ch; |
| 82 | int dump_width; | 84 | int dump_width; |
| 83 | 85 | ||
| 84 | trunc=0; | 86 | trc=0; |
| 85 | 87 | ||
| 86 | #ifdef TRUNCATE | 88 | #ifdef TRUNCATE |
| 87 | for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--) | 89 | for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--) |
| 88 | trunc++; | 90 | trc++; |
| 89 | #endif | 91 | #endif |
| 90 | 92 | ||
| 91 | if (indent < 0) | 93 | if (indent < 0) |
| @@ -96,7 +98,7 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) | |||
| 96 | memset(str,' ',indent); | 98 | memset(str,' ',indent); |
| 97 | } | 99 | } |
| 98 | str[indent]='\0'; | 100 | str[indent]='\0'; |
| 99 | 101 | ||
| 100 | dump_width=DUMP_WIDTH_LESS_INDENT(indent); | 102 | dump_width=DUMP_WIDTH_LESS_INDENT(indent); |
| 101 | rows=(len/dump_width); | 103 | rows=(len/dump_width); |
| 102 | if ((rows*dump_width)<len) | 104 | if ((rows*dump_width)<len) |
| @@ -117,7 +119,7 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) | |||
| 117 | { | 119 | { |
| 118 | ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; | 120 | ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; |
| 119 | BIO_snprintf(tmp,sizeof tmp,"%02x%c",ch, | 121 | BIO_snprintf(tmp,sizeof tmp,"%02x%c",ch, |
| 120 | j==7?'-':' '); | 122 | j==7?'-':' '); |
| 121 | BUF_strlcat(buf,tmp,sizeof buf); | 123 | BUF_strlcat(buf,tmp,sizeof buf); |
| 122 | } | 124 | } |
| 123 | } | 125 | } |
| @@ -129,28 +131,57 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) | |||
| 129 | ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; | 131 | ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; |
| 130 | #ifndef CHARSET_EBCDIC | 132 | #ifndef CHARSET_EBCDIC |
| 131 | BIO_snprintf(tmp,sizeof tmp,"%c", | 133 | BIO_snprintf(tmp,sizeof tmp,"%c", |
| 132 | ((ch>=' ')&&(ch<='~'))?ch:'.'); | 134 | ((ch>=' ')&&(ch<='~'))?ch:'.'); |
| 133 | #else | 135 | #else |
| 134 | BIO_snprintf(tmp,sizeof tmp,"%c", | 136 | BIO_snprintf(tmp,sizeof tmp,"%c", |
| 135 | ((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) | 137 | ((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) |
| 136 | ? os_toebcdic[ch] | 138 | ? os_toebcdic[ch] |
| 137 | : '.'); | 139 | : '.'); |
| 138 | #endif | 140 | #endif |
| 139 | BUF_strlcat(buf,tmp,sizeof buf); | 141 | BUF_strlcat(buf,tmp,sizeof buf); |
| 140 | } | 142 | } |
| 141 | BUF_strlcat(buf,"\n",sizeof buf); | 143 | BUF_strlcat(buf,"\n",sizeof buf); |
| 142 | /* if this is the last call then update the ddt_dump thing so that | 144 | /* if this is the last call then update the ddt_dump thing so |
| 143 | * we will move the selection point in the debug window | 145 | * that we will move the selection point in the debug window |
| 144 | */ | 146 | */ |
| 145 | ret+=BIO_write(bio,(char *)buf,strlen(buf)); | 147 | ret+=cb((void *)buf,strlen(buf),u); |
| 146 | } | 148 | } |
| 147 | #ifdef TRUNCATE | 149 | #ifdef TRUNCATE |
| 148 | if (trunc > 0) | 150 | if (trc > 0) |
| 149 | { | 151 | { |
| 150 | BIO_snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str, | 152 | BIO_snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str, |
| 151 | len+trunc); | 153 | len+trc); |
| 152 | ret+=BIO_write(bio,(char *)buf,strlen(buf)); | 154 | ret+=cb((void *)buf,strlen(buf),u); |
| 153 | } | 155 | } |
| 154 | #endif | 156 | #endif |
| 155 | return(ret); | 157 | return(ret); |
| 156 | } | 158 | } |
| 159 | |||
| 160 | #ifndef OPENSSL_NO_FP_API | ||
| 161 | static int write_fp(const void *data, size_t len, void *fp) | ||
| 162 | { | ||
| 163 | return UP_fwrite(data, len, 1, fp); | ||
| 164 | } | ||
| 165 | int BIO_dump_fp(FILE *fp, const char *s, int len) | ||
| 166 | { | ||
| 167 | return BIO_dump_cb(write_fp, fp, s, len); | ||
| 168 | } | ||
| 169 | int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent) | ||
| 170 | { | ||
| 171 | return BIO_dump_indent_cb(write_fp, fp, s, len, indent); | ||
| 172 | } | ||
| 173 | #endif | ||
| 174 | |||
| 175 | static int write_bio(const void *data, size_t len, void *bp) | ||
| 176 | { | ||
| 177 | return BIO_write((BIO *)bp, (const char *)data, len); | ||
| 178 | } | ||
| 179 | int BIO_dump(BIO *bp, const char *s, int len) | ||
| 180 | { | ||
| 181 | return BIO_dump_cb(write_bio, bp, s, len); | ||
| 182 | } | ||
| 183 | int BIO_dump_indent(BIO *bp, const char *s, int len, int indent) | ||
| 184 | { | ||
| 185 | return BIO_dump_indent_cb(write_bio, bp, s, len, indent); | ||
| 186 | } | ||
| 187 | |||
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index f2bd91d5a0..2fffcfc025 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c | |||
| @@ -79,7 +79,7 @@ | |||
| 79 | #include <openssl/bn.h> /* To get BN_LLONG properly defined */ | 79 | #include <openssl/bn.h> /* To get BN_LLONG properly defined */ |
| 80 | #include <openssl/bio.h> | 80 | #include <openssl/bio.h> |
| 81 | 81 | ||
| 82 | #ifdef BN_LLONG | 82 | #if defined(BN_LLONG) || defined(SIXTY_FOUR_BIT) |
| 83 | # ifndef HAVE_LONG_LONG | 83 | # ifndef HAVE_LONG_LONG |
| 84 | # define HAVE_LONG_LONG 1 | 84 | # define HAVE_LONG_LONG 1 |
| 85 | # endif | 85 | # endif |
| @@ -117,7 +117,7 @@ | |||
| 117 | 117 | ||
| 118 | #if HAVE_LONG_LONG | 118 | #if HAVE_LONG_LONG |
| 119 | # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) | 119 | # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) |
| 120 | # define LLONG _int64 | 120 | # define LLONG __int64 |
| 121 | # else | 121 | # else |
| 122 | # define LLONG long long | 122 | # define LLONG long long |
| 123 | # endif | 123 | # endif |
| @@ -482,7 +482,7 @@ fmtint( | |||
| 482 | int flags) | 482 | int flags) |
| 483 | { | 483 | { |
| 484 | int signvalue = 0; | 484 | int signvalue = 0; |
| 485 | char *prefix = ""; | 485 | const char *prefix = ""; |
| 486 | unsigned LLONG uvalue; | 486 | unsigned LLONG uvalue; |
| 487 | char convert[DECIMAL_SIZE(value)+3]; | 487 | char convert[DECIMAL_SIZE(value)+3]; |
| 488 | int place = 0; | 488 | int place = 0; |
| @@ -513,8 +513,8 @@ fmtint( | |||
| 513 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") | 513 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
| 514 | [uvalue % (unsigned) base]; | 514 | [uvalue % (unsigned) base]; |
| 515 | uvalue = (uvalue / (unsigned) base); | 515 | uvalue = (uvalue / (unsigned) base); |
| 516 | } while (uvalue && (place < sizeof convert)); | 516 | } while (uvalue && (place < (int)sizeof(convert))); |
| 517 | if (place == sizeof convert) | 517 | if (place == sizeof(convert)) |
| 518 | place--; | 518 | place--; |
| 519 | convert[place] = 0; | 519 | convert[place] = 0; |
| 520 | 520 | ||
| @@ -619,6 +619,7 @@ fmtfp( | |||
| 619 | int caps = 0; | 619 | int caps = 0; |
| 620 | long intpart; | 620 | long intpart; |
| 621 | long fracpart; | 621 | long fracpart; |
| 622 | long max10; | ||
| 622 | 623 | ||
| 623 | if (max < 0) | 624 | if (max < 0) |
| 624 | max = 6; | 625 | max = 6; |
| @@ -639,11 +640,12 @@ fmtfp( | |||
| 639 | 640 | ||
| 640 | /* we "cheat" by converting the fractional part to integer by | 641 | /* we "cheat" by converting the fractional part to integer by |
| 641 | multiplying by a factor of 10 */ | 642 | multiplying by a factor of 10 */ |
| 642 | fracpart = roundv((pow_10(max)) * (ufvalue - intpart)); | 643 | max10 = roundv(pow_10(max)); |
| 644 | fracpart = roundv(pow_10(max) * (ufvalue - intpart)); | ||
| 643 | 645 | ||
| 644 | if (fracpart >= (long)pow_10(max)) { | 646 | if (fracpart >= max10) { |
| 645 | intpart++; | 647 | intpart++; |
| 646 | fracpart -= (long)pow_10(max); | 648 | fracpart -= max10; |
| 647 | } | 649 | } |
| 648 | 650 | ||
| 649 | /* convert integer part */ | 651 | /* convert integer part */ |
| @@ -652,7 +654,7 @@ fmtfp( | |||
| 652 | (caps ? "0123456789ABCDEF" | 654 | (caps ? "0123456789ABCDEF" |
| 653 | : "0123456789abcdef")[intpart % 10]; | 655 | : "0123456789abcdef")[intpart % 10]; |
| 654 | intpart = (intpart / 10); | 656 | intpart = (intpart / 10); |
| 655 | } while (intpart && (iplace < sizeof iconvert)); | 657 | } while (intpart && (iplace < (int)sizeof(iconvert))); |
| 656 | if (iplace == sizeof iconvert) | 658 | if (iplace == sizeof iconvert) |
| 657 | iplace--; | 659 | iplace--; |
| 658 | iconvert[iplace] = 0; | 660 | iconvert[iplace] = 0; |
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index c851298d1e..ead477d8a2 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
| @@ -56,14 +56,21 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef OPENSSL_NO_SOCK | ||
| 60 | |||
| 61 | #include <stdio.h> | 59 | #include <stdio.h> |
| 62 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 63 | #include <errno.h> | 61 | #include <errno.h> |
| 64 | #define USE_SOCKETS | 62 | #define USE_SOCKETS |
| 65 | #include "cryptlib.h" | 63 | #include "cryptlib.h" |
| 66 | #include <openssl/bio.h> | 64 | #include <openssl/bio.h> |
| 65 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK) | ||
| 66 | #include <netdb.h> | ||
| 67 | #if defined(NETWARE_CLIB) | ||
| 68 | #include <sys/ioctl.h> | ||
| 69 | NETDB_DEFINE_CONTEXT | ||
| 70 | #endif | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #ifndef OPENSSL_NO_SOCK | ||
| 67 | 74 | ||
| 68 | #ifdef OPENSSL_SYS_WIN16 | 75 | #ifdef OPENSSL_SYS_WIN16 |
| 69 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 76 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| @@ -79,7 +86,7 @@ | |||
| 79 | #define MAX_LISTEN 32 | 86 | #define MAX_LISTEN 32 |
| 80 | #endif | 87 | #endif |
| 81 | 88 | ||
| 82 | #ifdef OPENSSL_SYS_WINDOWS | 89 | #if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) |
| 83 | static int wsa_init_done=0; | 90 | static int wsa_init_done=0; |
| 84 | #endif | 91 | #endif |
| 85 | 92 | ||
| @@ -175,11 +182,11 @@ int BIO_get_port(const char *str, unsigned short *port_ptr) | |||
| 175 | /* Note: under VMS with SOCKETSHR, it seems like the first | 182 | /* Note: under VMS with SOCKETSHR, it seems like the first |
| 176 | * parameter is 'char *', instead of 'const char *' | 183 | * parameter is 'char *', instead of 'const char *' |
| 177 | */ | 184 | */ |
| 178 | s=getservbyname( | ||
| 179 | #ifndef CONST_STRICT | 185 | #ifndef CONST_STRICT |
| 180 | (char *) | 186 | s=getservbyname((char *)str,"tcp"); |
| 187 | #else | ||
| 188 | s=getservbyname(str,"tcp"); | ||
| 181 | #endif | 189 | #endif |
| 182 | str,"tcp"); | ||
| 183 | if(s != NULL) | 190 | if(s != NULL) |
| 184 | *port_ptr=ntohs((unsigned short)s->s_port); | 191 | *port_ptr=ntohs((unsigned short)s->s_port); |
| 185 | CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); | 192 | CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); |
| @@ -357,7 +364,11 @@ struct hostent *BIO_gethostbyname(const char *name) | |||
| 357 | #if 1 | 364 | #if 1 |
| 358 | /* Caching gethostbyname() results forever is wrong, | 365 | /* Caching gethostbyname() results forever is wrong, |
| 359 | * so we have to let the true gethostbyname() worry about this */ | 366 | * so we have to let the true gethostbyname() worry about this */ |
| 367 | #if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__)) | ||
| 368 | return gethostbyname((char*)name); | ||
| 369 | #else | ||
| 360 | return gethostbyname(name); | 370 | return gethostbyname(name); |
| 371 | #endif | ||
| 361 | #else | 372 | #else |
| 362 | struct hostent *ret; | 373 | struct hostent *ret; |
| 363 | int i,lowi=0,j; | 374 | int i,lowi=0,j; |
| @@ -397,11 +408,11 @@ struct hostent *BIO_gethostbyname(const char *name) | |||
| 397 | /* Note: under VMS with SOCKETSHR, it seems like the first | 408 | /* Note: under VMS with SOCKETSHR, it seems like the first |
| 398 | * parameter is 'char *', instead of 'const char *' | 409 | * parameter is 'char *', instead of 'const char *' |
| 399 | */ | 410 | */ |
| 400 | ret=gethostbyname( | ||
| 401 | # ifndef CONST_STRICT | 411 | # ifndef CONST_STRICT |
| 402 | (char *) | 412 | ret=gethostbyname((char *)name); |
| 413 | # else | ||
| 414 | ret=gethostbyname(name); | ||
| 403 | # endif | 415 | # endif |
| 404 | name); | ||
| 405 | 416 | ||
| 406 | if (ret == NULL) | 417 | if (ret == NULL) |
| 407 | goto end; | 418 | goto end; |
| @@ -453,9 +464,6 @@ int BIO_sock_init(void) | |||
| 453 | { | 464 | { |
| 454 | int err; | 465 | int err; |
| 455 | 466 | ||
| 456 | #ifdef SIGINT | ||
| 457 | signal(SIGINT,(void (*)(int))BIO_sock_cleanup); | ||
| 458 | #endif | ||
| 459 | wsa_init_done=1; | 467 | wsa_init_done=1; |
| 460 | memset(&wsa_state,0,sizeof(wsa_state)); | 468 | memset(&wsa_state,0,sizeof(wsa_state)); |
| 461 | if (WSAStartup(0x0101,&wsa_state)!=0) | 469 | if (WSAStartup(0x0101,&wsa_state)!=0) |
| @@ -473,6 +481,26 @@ int BIO_sock_init(void) | |||
| 473 | if (sock_init()) | 481 | if (sock_init()) |
| 474 | return (-1); | 482 | return (-1); |
| 475 | #endif | 483 | #endif |
| 484 | |||
| 485 | #if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
| 486 | WORD wVerReq; | ||
| 487 | WSADATA wsaData; | ||
| 488 | int err; | ||
| 489 | |||
| 490 | if (!wsa_init_done) | ||
| 491 | { | ||
| 492 | wsa_init_done=1; | ||
| 493 | wVerReq = MAKEWORD( 2, 0 ); | ||
| 494 | err = WSAStartup(wVerReq,&wsaData); | ||
| 495 | if (err != 0) | ||
| 496 | { | ||
| 497 | SYSerr(SYS_F_WSASTARTUP,err); | ||
| 498 | BIOerr(BIO_F_BIO_SOCK_INIT,BIO_R_WSASTARTUP); | ||
| 499 | return(-1); | ||
| 500 | } | ||
| 501 | } | ||
| 502 | #endif | ||
| 503 | |||
| 476 | return(1); | 504 | return(1); |
| 477 | } | 505 | } |
| 478 | 506 | ||
| @@ -483,10 +511,16 @@ void BIO_sock_cleanup(void) | |||
| 483 | { | 511 | { |
| 484 | wsa_init_done=0; | 512 | wsa_init_done=0; |
| 485 | #ifndef OPENSSL_SYS_WINCE | 513 | #ifndef OPENSSL_SYS_WINCE |
| 486 | WSACancelBlockingCall(); | 514 | WSACancelBlockingCall(); /* Winsock 1.1 specific */ |
| 487 | #endif | 515 | #endif |
| 488 | WSACleanup(); | 516 | WSACleanup(); |
| 489 | } | 517 | } |
| 518 | #elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
| 519 | if (wsa_init_done) | ||
| 520 | { | ||
| 521 | wsa_init_done=0; | ||
| 522 | WSACleanup(); | ||
| 523 | } | ||
| 490 | #endif | 524 | #endif |
| 491 | } | 525 | } |
| 492 | 526 | ||
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index 1ce2bfacc0..c72a23c2e1 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c | |||
| @@ -127,7 +127,7 @@ static int nbiof_read(BIO *b, char *out, int outl) | |||
| 127 | { | 127 | { |
| 128 | NBIO_TEST *nt; | 128 | NBIO_TEST *nt; |
| 129 | int ret=0; | 129 | int ret=0; |
| 130 | #if 0 | 130 | #if 1 |
| 131 | int num; | 131 | int num; |
| 132 | unsigned char n; | 132 | unsigned char n; |
| 133 | #endif | 133 | #endif |
| @@ -137,7 +137,7 @@ static int nbiof_read(BIO *b, char *out, int outl) | |||
| 137 | nt=(NBIO_TEST *)b->ptr; | 137 | nt=(NBIO_TEST *)b->ptr; |
| 138 | 138 | ||
| 139 | BIO_clear_retry_flags(b); | 139 | BIO_clear_retry_flags(b); |
| 140 | #if 0 | 140 | #if 1 |
| 141 | RAND_pseudo_bytes(&n,1); | 141 | RAND_pseudo_bytes(&n,1); |
| 142 | num=(n&0x07); | 142 | num=(n&0x07); |
| 143 | 143 | ||
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 2eb703830f..cecb6a7207 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
| @@ -59,13 +59,14 @@ | |||
| 59 | #ifndef HEADER_BIO_H | 59 | #ifndef HEADER_BIO_H |
| 60 | #define HEADER_BIO_H | 60 | #define HEADER_BIO_H |
| 61 | 61 | ||
| 62 | #include <openssl/e_os2.h> | ||
| 63 | |||
| 62 | #ifndef OPENSSL_NO_FP_API | 64 | #ifndef OPENSSL_NO_FP_API |
| 63 | # include <stdio.h> | 65 | # include <stdio.h> |
| 64 | #endif | 66 | #endif |
| 65 | #include <stdarg.h> | 67 | #include <stdarg.h> |
| 66 | 68 | ||
| 67 | #include <openssl/crypto.h> | 69 | #include <openssl/crypto.h> |
| 68 | #include <openssl/e_os2.h> | ||
| 69 | 70 | ||
| 70 | #ifdef __cplusplus | 71 | #ifdef __cplusplus |
| 71 | extern "C" { | 72 | extern "C" { |
| @@ -93,6 +94,8 @@ extern "C" { | |||
| 93 | #define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ | 94 | #define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ |
| 94 | #define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ | 95 | #define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ |
| 95 | #define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ | 96 | #define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ |
| 97 | #define BIO_TYPE_DGRAM (21|0x0400|0x0100) | ||
| 98 | #define BIO_TYPE_COMP (23|0x0200) /* filter */ | ||
| 96 | 99 | ||
| 97 | #define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ | 100 | #define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ |
| 98 | #define BIO_TYPE_FILTER 0x0200 | 101 | #define BIO_TYPE_FILTER 0x0200 |
| @@ -124,6 +127,38 @@ extern "C" { | |||
| 124 | 127 | ||
| 125 | #define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ | 128 | #define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ |
| 126 | 129 | ||
| 130 | /* dgram BIO stuff */ | ||
| 131 | #define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ | ||
| 132 | #define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally | ||
| 133 | * connected socket to be | ||
| 134 | * passed in */ | ||
| 135 | #define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ | ||
| 136 | #define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ | ||
| 137 | #define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ | ||
| 138 | #define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ | ||
| 139 | |||
| 140 | #define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ | ||
| 141 | #define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ | ||
| 142 | |||
| 143 | /* #ifdef IP_MTU_DISCOVER */ | ||
| 144 | #define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ | ||
| 145 | /* #endif */ | ||
| 146 | |||
| 147 | #define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ | ||
| 148 | #define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ | ||
| 149 | #define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for | ||
| 150 | * MTU. want to use this | ||
| 151 | * if asking the kernel | ||
| 152 | * fails */ | ||
| 153 | |||
| 154 | #define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU | ||
| 155 | * was exceed in the | ||
| 156 | * previous write | ||
| 157 | * operation */ | ||
| 158 | |||
| 159 | #define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ | ||
| 160 | |||
| 161 | |||
| 127 | /* modifiers */ | 162 | /* modifiers */ |
| 128 | #define BIO_FP_READ 0x02 | 163 | #define BIO_FP_READ 0x02 |
| 129 | #define BIO_FP_WRITE 0x04 | 164 | #define BIO_FP_WRITE 0x04 |
| @@ -135,6 +170,11 @@ extern "C" { | |||
| 135 | #define BIO_FLAGS_IO_SPECIAL 0x04 | 170 | #define BIO_FLAGS_IO_SPECIAL 0x04 |
| 136 | #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) | 171 | #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) |
| 137 | #define BIO_FLAGS_SHOULD_RETRY 0x08 | 172 | #define BIO_FLAGS_SHOULD_RETRY 0x08 |
| 173 | #ifndef BIO_FLAGS_UPLINK | ||
| 174 | /* "UPLINK" flag denotes file descriptors provided by application. | ||
| 175 | It defaults to 0, as most platforms don't require UPLINK interface. */ | ||
| 176 | #define BIO_FLAGS_UPLINK 0 | ||
| 177 | #endif | ||
| 138 | 178 | ||
| 139 | /* Used in BIO_gethostbyname() */ | 179 | /* Used in BIO_gethostbyname() */ |
| 140 | #define BIO_GHBN_CTRL_HITS 1 | 180 | #define BIO_GHBN_CTRL_HITS 1 |
| @@ -157,28 +197,32 @@ extern "C" { | |||
| 157 | */ | 197 | */ |
| 158 | #define BIO_FLAGS_MEM_RDONLY 0x200 | 198 | #define BIO_FLAGS_MEM_RDONLY 0x200 |
| 159 | 199 | ||
| 160 | #define BIO_set_flags(b,f) ((b)->flags|=(f)) | 200 | typedef struct bio_st BIO; |
| 161 | #define BIO_get_flags(b) ((b)->flags) | 201 | |
| 202 | void BIO_set_flags(BIO *b, int flags); | ||
| 203 | int BIO_test_flags(const BIO *b, int flags); | ||
| 204 | void BIO_clear_flags(BIO *b, int flags); | ||
| 205 | |||
| 206 | #define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) | ||
| 162 | #define BIO_set_retry_special(b) \ | 207 | #define BIO_set_retry_special(b) \ |
| 163 | ((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) | 208 | BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) |
| 164 | #define BIO_set_retry_read(b) \ | 209 | #define BIO_set_retry_read(b) \ |
| 165 | ((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) | 210 | BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) |
| 166 | #define BIO_set_retry_write(b) \ | 211 | #define BIO_set_retry_write(b) \ |
| 167 | ((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) | 212 | BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) |
| 168 | 213 | ||
| 169 | /* These are normally used internally in BIOs */ | 214 | /* These are normally used internally in BIOs */ |
| 170 | #define BIO_clear_flags(b,f) ((b)->flags&= ~(f)) | ||
| 171 | #define BIO_clear_retry_flags(b) \ | 215 | #define BIO_clear_retry_flags(b) \ |
| 172 | ((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) | 216 | BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) |
| 173 | #define BIO_get_retry_flags(b) \ | 217 | #define BIO_get_retry_flags(b) \ |
| 174 | ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) | 218 | BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) |
| 175 | 219 | ||
| 176 | /* These should be used by the application to tell why we should retry */ | 220 | /* These should be used by the application to tell why we should retry */ |
| 177 | #define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) | 221 | #define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) |
| 178 | #define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) | 222 | #define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) |
| 179 | #define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) | 223 | #define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) |
| 180 | #define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS) | 224 | #define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) |
| 181 | #define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY) | 225 | #define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) |
| 182 | 226 | ||
| 183 | /* The next three are used in conjunction with the | 227 | /* The next three are used in conjunction with the |
| 184 | * BIO_should_io_special() condition. After this returns true, | 228 | * BIO_should_io_special() condition. After this returns true, |
| @@ -207,14 +251,14 @@ extern "C" { | |||
| 207 | #define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) | 251 | #define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) |
| 208 | #define BIO_cb_post(a) ((a)&BIO_CB_RETURN) | 252 | #define BIO_cb_post(a) ((a)&BIO_CB_RETURN) |
| 209 | 253 | ||
| 210 | #define BIO_set_callback(b,cb) ((b)->callback=(cb)) | 254 | long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long); |
| 211 | #define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg)) | 255 | void BIO_set_callback(BIO *b, |
| 212 | #define BIO_get_callback_arg(b) ((b)->cb_arg) | 256 | long (*callback)(struct bio_st *,int,const char *,int, long,long)); |
| 213 | #define BIO_get_callback(b) ((b)->callback) | 257 | char *BIO_get_callback_arg(const BIO *b); |
| 214 | #define BIO_method_name(b) ((b)->method->name) | 258 | void BIO_set_callback_arg(BIO *b, char *arg); |
| 215 | #define BIO_method_type(b) ((b)->method->type) | ||
| 216 | 259 | ||
| 217 | typedef struct bio_st BIO; | 260 | const char * BIO_method_name(const BIO *b); |
| 261 | int BIO_method_type(const BIO *b); | ||
| 218 | 262 | ||
| 219 | typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); | 263 | typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); |
| 220 | 264 | ||
| @@ -488,6 +532,18 @@ size_t BIO_ctrl_get_write_guarantee(BIO *b); | |||
| 488 | size_t BIO_ctrl_get_read_request(BIO *b); | 532 | size_t BIO_ctrl_get_read_request(BIO *b); |
| 489 | int BIO_ctrl_reset_read_request(BIO *b); | 533 | int BIO_ctrl_reset_read_request(BIO *b); |
| 490 | 534 | ||
| 535 | /* ctrl macros for dgram */ | ||
| 536 | #define BIO_ctrl_dgram_connect(b,peer) \ | ||
| 537 | (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) | ||
| 538 | #define BIO_ctrl_set_connected(b, state, peer) \ | ||
| 539 | (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) | ||
| 540 | #define BIO_dgram_recv_timedout(b) \ | ||
| 541 | (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) | ||
| 542 | #define BIO_dgram_send_timedout(b) \ | ||
| 543 | (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) | ||
| 544 | #define BIO_dgram_set_peer(b,peer) \ | ||
| 545 | (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) | ||
| 546 | |||
| 491 | /* These two aren't currently implemented */ | 547 | /* These two aren't currently implemented */ |
| 492 | /* int BIO_get_ex_num(BIO *bio); */ | 548 | /* int BIO_get_ex_num(BIO *bio); */ |
| 493 | /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ | 549 | /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ |
| @@ -567,15 +623,28 @@ BIO_METHOD *BIO_f_buffer(void); | |||
| 567 | BIO_METHOD *BIO_f_linebuffer(void); | 623 | BIO_METHOD *BIO_f_linebuffer(void); |
| 568 | #endif | 624 | #endif |
| 569 | BIO_METHOD *BIO_f_nbio_test(void); | 625 | BIO_METHOD *BIO_f_nbio_test(void); |
| 626 | #ifndef OPENSSL_NO_DGRAM | ||
| 627 | BIO_METHOD *BIO_s_datagram(void); | ||
| 628 | #endif | ||
| 629 | |||
| 570 | /* BIO_METHOD *BIO_f_ber(void); */ | 630 | /* BIO_METHOD *BIO_f_ber(void); */ |
| 571 | 631 | ||
| 572 | int BIO_sock_should_retry(int i); | 632 | int BIO_sock_should_retry(int i); |
| 573 | int BIO_sock_non_fatal_error(int error); | 633 | int BIO_sock_non_fatal_error(int error); |
| 634 | int BIO_dgram_non_fatal_error(int error); | ||
| 635 | |||
| 574 | int BIO_fd_should_retry(int i); | 636 | int BIO_fd_should_retry(int i); |
| 575 | int BIO_fd_non_fatal_error(int error); | 637 | int BIO_fd_non_fatal_error(int error); |
| 638 | int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), | ||
| 639 | void *u, const char *s, int len); | ||
| 640 | int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | ||
| 641 | void *u, const char *s, int len, int indent); | ||
| 576 | int BIO_dump(BIO *b,const char *bytes,int len); | 642 | int BIO_dump(BIO *b,const char *bytes,int len); |
| 577 | int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); | 643 | int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); |
| 578 | 644 | #ifndef OPENSSL_NO_FP_API | |
| 645 | int BIO_dump_fp(FILE *fp, const char *s, int len); | ||
| 646 | int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); | ||
| 647 | #endif | ||
| 579 | struct hostent *BIO_gethostbyname(const char *name); | 648 | struct hostent *BIO_gethostbyname(const char *name); |
| 580 | /* We might want a thread-safe interface too: | 649 | /* We might want a thread-safe interface too: |
| 581 | * struct hostent *BIO_gethostbyname_r(const char *name, | 650 | * struct hostent *BIO_gethostbyname_r(const char *name, |
| @@ -597,6 +666,7 @@ void BIO_sock_cleanup(void); | |||
| 597 | int BIO_set_tcp_ndelay(int sock,int turn_on); | 666 | int BIO_set_tcp_ndelay(int sock,int turn_on); |
| 598 | 667 | ||
| 599 | BIO *BIO_new_socket(int sock, int close_flag); | 668 | BIO *BIO_new_socket(int sock, int close_flag); |
| 669 | BIO *BIO_new_dgram(int fd, int close_flag); | ||
| 600 | BIO *BIO_new_fd(int fd, int close_flag); | 670 | BIO *BIO_new_fd(int fd, int close_flag); |
| 601 | BIO *BIO_new_connect(char *host_port); | 671 | BIO *BIO_new_connect(char *host_port); |
| 602 | BIO *BIO_new_accept(char *host_port); | 672 | BIO *BIO_new_accept(char *host_port); |
| @@ -612,10 +682,20 @@ void BIO_copy_next_retry(BIO *b); | |||
| 612 | 682 | ||
| 613 | /*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ | 683 | /*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ |
| 614 | 684 | ||
| 615 | int BIO_printf(BIO *bio, const char *format, ...); | 685 | #ifdef __GNUC__ |
| 616 | int BIO_vprintf(BIO *bio, const char *format, va_list args); | 686 | # define __bio_h__attr__ __attribute__ |
| 617 | int BIO_snprintf(char *buf, size_t n, const char *format, ...); | 687 | #else |
| 618 | int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args); | 688 | # define __bio_h__attr__(x) |
| 689 | #endif | ||
| 690 | int BIO_printf(BIO *bio, const char *format, ...) | ||
| 691 | __bio_h__attr__((__format__(__printf__,2,3))); | ||
| 692 | int BIO_vprintf(BIO *bio, const char *format, va_list args) | ||
| 693 | __bio_h__attr__((__format__(__printf__,2,0))); | ||
| 694 | int BIO_snprintf(char *buf, size_t n, const char *format, ...) | ||
| 695 | __bio_h__attr__((__format__(__printf__,3,4))); | ||
| 696 | int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) | ||
| 697 | __bio_h__attr__((__format__(__printf__,3,0))); | ||
| 698 | #undef __bio_h__attr__ | ||
| 619 | 699 | ||
| 620 | /* BEGIN ERROR CODES */ | 700 | /* BEGIN ERROR CODES */ |
| 621 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 701 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| @@ -629,6 +709,7 @@ void ERR_load_BIO_strings(void); | |||
| 629 | #define BIO_F_ACPT_STATE 100 | 709 | #define BIO_F_ACPT_STATE 100 |
| 630 | #define BIO_F_BIO_ACCEPT 101 | 710 | #define BIO_F_BIO_ACCEPT 101 |
| 631 | #define BIO_F_BIO_BER_GET_HEADER 102 | 711 | #define BIO_F_BIO_BER_GET_HEADER 102 |
| 712 | #define BIO_F_BIO_CALLBACK_CTRL 131 | ||
| 632 | #define BIO_F_BIO_CTRL 103 | 713 | #define BIO_F_BIO_CTRL 103 |
| 633 | #define BIO_F_BIO_GETHOSTBYNAME 120 | 714 | #define BIO_F_BIO_GETHOSTBYNAME 120 |
| 634 | #define BIO_F_BIO_GETS 104 | 715 | #define BIO_F_BIO_GETS 104 |
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c index 8859a58ae4..6603f1c74d 100644 --- a/src/lib/libcrypto/bio/bio_err.c +++ b/src/lib/libcrypto/bio/bio_err.c | |||
| @@ -73,6 +73,7 @@ static ERR_STRING_DATA BIO_str_functs[]= | |||
| 73 | {ERR_FUNC(BIO_F_ACPT_STATE), "ACPT_STATE"}, | 73 | {ERR_FUNC(BIO_F_ACPT_STATE), "ACPT_STATE"}, |
| 74 | {ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"}, | 74 | {ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"}, |
| 75 | {ERR_FUNC(BIO_F_BIO_BER_GET_HEADER), "BIO_BER_GET_HEADER"}, | 75 | {ERR_FUNC(BIO_F_BIO_BER_GET_HEADER), "BIO_BER_GET_HEADER"}, |
| 76 | {ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"}, | ||
| 76 | {ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"}, | 77 | {ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"}, |
| 77 | {ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"}, | 78 | {ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"}, |
| 78 | {ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"}, | 79 | {ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"}, |
| @@ -142,15 +143,12 @@ static ERR_STRING_DATA BIO_str_reasons[]= | |||
| 142 | 143 | ||
| 143 | void ERR_load_BIO_strings(void) | 144 | void ERR_load_BIO_strings(void) |
| 144 | { | 145 | { |
| 145 | static int init=1; | 146 | #ifndef OPENSSL_NO_ERR |
| 146 | 147 | ||
| 147 | if (init) | 148 | if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) |
| 148 | { | 149 | { |
| 149 | init=0; | ||
| 150 | #ifndef OPENSSL_NO_ERR | ||
| 151 | ERR_load_strings(0,BIO_str_functs); | 150 | ERR_load_strings(0,BIO_str_functs); |
| 152 | ERR_load_strings(0,BIO_str_reasons); | 151 | ERR_load_strings(0,BIO_str_reasons); |
| 153 | #endif | ||
| 154 | |||
| 155 | } | 152 | } |
| 153 | #endif | ||
| 156 | } | 154 | } |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 692c8fb5c6..3f52ae953c 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
| @@ -141,10 +141,56 @@ int BIO_free(BIO *a) | |||
| 141 | void BIO_vfree(BIO *a) | 141 | void BIO_vfree(BIO *a) |
| 142 | { BIO_free(a); } | 142 | { BIO_free(a); } |
| 143 | 143 | ||
| 144 | void BIO_clear_flags(BIO *b, int flags) | ||
| 145 | { | ||
| 146 | b->flags &= ~flags; | ||
| 147 | } | ||
| 148 | |||
| 149 | int BIO_test_flags(const BIO *b, int flags) | ||
| 150 | { | ||
| 151 | return (b->flags & flags); | ||
| 152 | } | ||
| 153 | |||
| 154 | void BIO_set_flags(BIO *b, int flags) | ||
| 155 | { | ||
| 156 | b->flags |= flags; | ||
| 157 | } | ||
| 158 | |||
| 159 | long (*BIO_get_callback(const BIO *b))(struct bio_st *,int,const char *,int, long,long) | ||
| 160 | { | ||
| 161 | return b->callback; | ||
| 162 | } | ||
| 163 | |||
| 164 | void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *,int,const char *,int, long,long)) | ||
| 165 | { | ||
| 166 | b->callback = cb; | ||
| 167 | } | ||
| 168 | |||
| 169 | void BIO_set_callback_arg(BIO *b, char *arg) | ||
| 170 | { | ||
| 171 | b->cb_arg = arg; | ||
| 172 | } | ||
| 173 | |||
| 174 | char * BIO_get_callback_arg(const BIO *b) | ||
| 175 | { | ||
| 176 | return b->cb_arg; | ||
| 177 | } | ||
| 178 | |||
| 179 | const char * BIO_method_name(const BIO *b) | ||
| 180 | { | ||
| 181 | return b->method->name; | ||
| 182 | } | ||
| 183 | |||
| 184 | int BIO_method_type(const BIO *b) | ||
| 185 | { | ||
| 186 | return b->method->type; | ||
| 187 | } | ||
| 188 | |||
| 189 | |||
| 144 | int BIO_read(BIO *b, void *out, int outl) | 190 | int BIO_read(BIO *b, void *out, int outl) |
| 145 | { | 191 | { |
| 146 | int i; | 192 | int i; |
| 147 | long (*cb)(); | 193 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 148 | 194 | ||
| 149 | if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) | 195 | if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) |
| 150 | { | 196 | { |
| @@ -176,7 +222,7 @@ int BIO_read(BIO *b, void *out, int outl) | |||
| 176 | int BIO_write(BIO *b, const void *in, int inl) | 222 | int BIO_write(BIO *b, const void *in, int inl) |
| 177 | { | 223 | { |
| 178 | int i; | 224 | int i; |
| 179 | long (*cb)(); | 225 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 180 | 226 | ||
| 181 | if (b == NULL) | 227 | if (b == NULL) |
| 182 | return(0); | 228 | return(0); |
| @@ -211,7 +257,7 @@ int BIO_write(BIO *b, const void *in, int inl) | |||
| 211 | int BIO_puts(BIO *b, const char *in) | 257 | int BIO_puts(BIO *b, const char *in) |
| 212 | { | 258 | { |
| 213 | int i; | 259 | int i; |
| 214 | long (*cb)(); | 260 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 215 | 261 | ||
| 216 | if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) | 262 | if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) |
| 217 | { | 263 | { |
| @@ -244,7 +290,7 @@ int BIO_puts(BIO *b, const char *in) | |||
| 244 | int BIO_gets(BIO *b, char *in, int inl) | 290 | int BIO_gets(BIO *b, char *in, int inl) |
| 245 | { | 291 | { |
| 246 | int i; | 292 | int i; |
| 247 | long (*cb)(); | 293 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 248 | 294 | ||
| 249 | if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) | 295 | if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) |
| 250 | { | 296 | { |
| @@ -305,7 +351,7 @@ char *BIO_ptr_ctrl(BIO *b, int cmd, long larg) | |||
| 305 | long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) | 351 | long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) |
| 306 | { | 352 | { |
| 307 | long ret; | 353 | long ret; |
| 308 | long (*cb)(); | 354 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 309 | 355 | ||
| 310 | if (b == NULL) return(0); | 356 | if (b == NULL) return(0); |
| 311 | 357 | ||
| @@ -332,13 +378,13 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) | |||
| 332 | long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)) | 378 | long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)) |
| 333 | { | 379 | { |
| 334 | long ret; | 380 | long ret; |
| 335 | long (*cb)(); | 381 | long (*cb)(BIO *,int,const char *,int,long,long); |
| 336 | 382 | ||
| 337 | if (b == NULL) return(0); | 383 | if (b == NULL) return(0); |
| 338 | 384 | ||
| 339 | if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) | 385 | if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) |
| 340 | { | 386 | { |
| 341 | BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD); | 387 | BIOerr(BIO_F_BIO_CALLBACK_CTRL,BIO_R_UNSUPPORTED_METHOD); |
| 342 | return(-2); | 388 | return(-2); |
| 343 | } | 389 | } |
| 344 | 390 | ||
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c index 8ea1db158b..d090b7272f 100644 --- a/src/lib/libcrypto/bio/bss_acpt.c +++ b/src/lib/libcrypto/bio/bss_acpt.c | |||
| @@ -56,14 +56,14 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef OPENSSL_NO_SOCK | ||
| 60 | |||
| 61 | #include <stdio.h> | 59 | #include <stdio.h> |
| 62 | #include <errno.h> | 60 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 61 | #define USE_SOCKETS |
| 64 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 65 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
| 66 | 64 | ||
| 65 | #ifndef OPENSSL_NO_SOCK | ||
| 66 | |||
| 67 | #ifdef OPENSSL_SYS_WIN16 | 67 | #ifdef OPENSSL_SYS_WIN16 |
| 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| 69 | #else | 69 | #else |
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index 216780ed5e..c14727855b 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c | |||
| @@ -56,14 +56,14 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef OPENSSL_NO_SOCK | ||
| 60 | |||
| 61 | #include <stdio.h> | 59 | #include <stdio.h> |
| 62 | #include <errno.h> | 60 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 61 | #define USE_SOCKETS |
| 64 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 65 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
| 66 | 64 | ||
| 65 | #ifndef OPENSSL_NO_SOCK | ||
| 66 | |||
| 67 | #ifdef OPENSSL_SYS_WIN16 | 67 | #ifdef OPENSSL_SYS_WIN16 |
| 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| 69 | #else | 69 | #else |
| @@ -130,7 +130,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c) | |||
| 130 | int ret= -1,i; | 130 | int ret= -1,i; |
| 131 | unsigned long l; | 131 | unsigned long l; |
| 132 | char *p,*q; | 132 | char *p,*q; |
| 133 | int (*cb)()=NULL; | 133 | int (*cb)(const BIO *,int,int)=NULL; |
| 134 | 134 | ||
| 135 | if (c->info_callback != NULL) | 135 | if (c->info_callback != NULL) |
| 136 | cb=c->info_callback; | 136 | cb=c->info_callback; |
| @@ -590,9 +590,9 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 590 | break; | 590 | break; |
| 591 | case BIO_CTRL_GET_CALLBACK: | 591 | case BIO_CTRL_GET_CALLBACK: |
| 592 | { | 592 | { |
| 593 | int (**fptr)(); | 593 | int (**fptr)(const BIO *bio,int state,int xret); |
| 594 | 594 | ||
| 595 | fptr=(int (**)())ptr; | 595 | fptr=(int (**)(const BIO *bio,int state,int xret))ptr; |
| 596 | *fptr=data->info_callback; | 596 | *fptr=data->info_callback; |
| 597 | } | 597 | } |
| 598 | break; | 598 | break; |
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c index 5e3e187de6..4c229bf641 100644 --- a/src/lib/libcrypto/bio/bss_fd.c +++ b/src/lib/libcrypto/bio/bss_fd.c | |||
| @@ -60,7 +60,19 @@ | |||
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #define USE_SOCKETS | 61 | #define USE_SOCKETS |
| 62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 63 | #include <openssl/bio.h> | 63 | /* |
| 64 | * As for unconditional usage of "UPLINK" interface in this module. | ||
| 65 | * Trouble is that unlike Unix file descriptors [which are indexes | ||
| 66 | * in kernel-side per-process table], corresponding descriptors on | ||
| 67 | * platforms which require "UPLINK" interface seem to be indexes | ||
| 68 | * in a user-land, non-global table. Well, in fact they are indexes | ||
| 69 | * in stdio _iob[], and recall that _iob[] was the very reason why | ||
| 70 | * "UPLINK" interface was introduced in first place. But one way on | ||
| 71 | * another. Neither libcrypto or libssl use this BIO meaning that | ||
| 72 | * file descriptors can only be provided by application. Therefore | ||
| 73 | * "UPLINK" calls are due... | ||
| 74 | */ | ||
| 75 | #include "bio_lcl.h" | ||
| 64 | 76 | ||
| 65 | static int fd_write(BIO *h, const char *buf, int num); | 77 | static int fd_write(BIO *h, const char *buf, int num); |
| 66 | static int fd_read(BIO *h, char *buf, int size); | 78 | static int fd_read(BIO *h, char *buf, int size); |
| @@ -100,9 +112,9 @@ BIO *BIO_new_fd(int fd,int close_flag) | |||
| 100 | static int fd_new(BIO *bi) | 112 | static int fd_new(BIO *bi) |
| 101 | { | 113 | { |
| 102 | bi->init=0; | 114 | bi->init=0; |
| 103 | bi->num=0; | 115 | bi->num=-1; |
| 104 | bi->ptr=NULL; | 116 | bi->ptr=NULL; |
| 105 | bi->flags=0; | 117 | bi->flags=BIO_FLAGS_UPLINK; /* essentially redundant */ |
| 106 | return(1); | 118 | return(1); |
| 107 | } | 119 | } |
| 108 | 120 | ||
| @@ -113,10 +125,10 @@ static int fd_free(BIO *a) | |||
| 113 | { | 125 | { |
| 114 | if (a->init) | 126 | if (a->init) |
| 115 | { | 127 | { |
| 116 | close(a->num); | 128 | UP_close(a->num); |
| 117 | } | 129 | } |
| 118 | a->init=0; | 130 | a->init=0; |
| 119 | a->flags=0; | 131 | a->flags=BIO_FLAGS_UPLINK; |
| 120 | } | 132 | } |
| 121 | return(1); | 133 | return(1); |
| 122 | } | 134 | } |
| @@ -128,7 +140,7 @@ static int fd_read(BIO *b, char *out,int outl) | |||
| 128 | if (out != NULL) | 140 | if (out != NULL) |
| 129 | { | 141 | { |
| 130 | clear_sys_error(); | 142 | clear_sys_error(); |
| 131 | ret=read(b->num,out,outl); | 143 | ret=UP_read(b->num,out,outl); |
| 132 | BIO_clear_retry_flags(b); | 144 | BIO_clear_retry_flags(b); |
| 133 | if (ret <= 0) | 145 | if (ret <= 0) |
| 134 | { | 146 | { |
| @@ -143,7 +155,7 @@ static int fd_write(BIO *b, const char *in, int inl) | |||
| 143 | { | 155 | { |
| 144 | int ret; | 156 | int ret; |
| 145 | clear_sys_error(); | 157 | clear_sys_error(); |
| 146 | ret=write(b->num,in,inl); | 158 | ret=UP_write(b->num,in,inl); |
| 147 | BIO_clear_retry_flags(b); | 159 | BIO_clear_retry_flags(b); |
| 148 | if (ret <= 0) | 160 | if (ret <= 0) |
| 149 | { | 161 | { |
| @@ -163,11 +175,11 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 163 | case BIO_CTRL_RESET: | 175 | case BIO_CTRL_RESET: |
| 164 | num=0; | 176 | num=0; |
| 165 | case BIO_C_FILE_SEEK: | 177 | case BIO_C_FILE_SEEK: |
| 166 | ret=(long)lseek(b->num,num,0); | 178 | ret=(long)UP_lseek(b->num,num,0); |
| 167 | break; | 179 | break; |
| 168 | case BIO_C_FILE_TELL: | 180 | case BIO_C_FILE_TELL: |
| 169 | case BIO_CTRL_INFO: | 181 | case BIO_CTRL_INFO: |
| 170 | ret=(long)lseek(b->num,0,1); | 182 | ret=(long)UP_lseek(b->num,0,1); |
| 171 | break; | 183 | break; |
| 172 | case BIO_C_SET_FD: | 184 | case BIO_C_SET_FD: |
| 173 | fd_free(b); | 185 | fd_free(b); |
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 58fade9f29..0c8c8115fa 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
| @@ -65,12 +65,34 @@ | |||
| 65 | #ifndef HEADER_BSS_FILE_C | 65 | #ifndef HEADER_BSS_FILE_C |
| 66 | #define HEADER_BSS_FILE_C | 66 | #define HEADER_BSS_FILE_C |
| 67 | 67 | ||
| 68 | #if defined(__linux) || defined(__sun) || defined(__hpux) | ||
| 69 | /* Following definition aliases fopen to fopen64 on above mentioned | ||
| 70 | * platforms. This makes it possible to open and sequentially access | ||
| 71 | * files larger than 2GB from 32-bit application. It does not allow to | ||
| 72 | * traverse them beyond 2GB with fseek/ftell, but on the other hand *no* | ||
| 73 | * 32-bit platform permits that, not with fseek/ftell. Not to mention | ||
| 74 | * that breaking 2GB limit for seeking would require surgery to *our* | ||
| 75 | * API. But sequential access suffices for practical cases when you | ||
| 76 | * can run into large files, such as fingerprinting, so we can let API | ||
| 77 | * alone. For reference, the list of 32-bit platforms which allow for | ||
| 78 | * sequential access of large files without extra "magic" comprise *BSD, | ||
| 79 | * Darwin, IRIX... | ||
| 80 | */ | ||
| 81 | #ifndef _FILE_OFFSET_BITS | ||
| 82 | #define _FILE_OFFSET_BITS 64 | ||
| 83 | #endif | ||
| 84 | #endif | ||
| 85 | |||
| 68 | #include <stdio.h> | 86 | #include <stdio.h> |
| 69 | #include <errno.h> | 87 | #include <errno.h> |
| 70 | #include "cryptlib.h" | 88 | #include "cryptlib.h" |
| 71 | #include <openssl/bio.h> | 89 | #include "bio_lcl.h" |
| 72 | #include <openssl/err.h> | 90 | #include <openssl/err.h> |
| 73 | 91 | ||
| 92 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
| 93 | #include <nwfileio.h> | ||
| 94 | #endif | ||
| 95 | |||
| 74 | #if !defined(OPENSSL_NO_STDIO) | 96 | #if !defined(OPENSSL_NO_STDIO) |
| 75 | 97 | ||
| 76 | static int MS_CALLBACK file_write(BIO *h, const char *buf, int num); | 98 | static int MS_CALLBACK file_write(BIO *h, const char *buf, int num); |
| @@ -110,8 +132,12 @@ BIO *BIO_new_file(const char *filename, const char *mode) | |||
| 110 | return(NULL); | 132 | return(NULL); |
| 111 | } | 133 | } |
| 112 | if ((ret=BIO_new(BIO_s_file_internal())) == NULL) | 134 | if ((ret=BIO_new(BIO_s_file_internal())) == NULL) |
| 135 | { | ||
| 136 | fclose(file); | ||
| 113 | return(NULL); | 137 | return(NULL); |
| 138 | } | ||
| 114 | 139 | ||
| 140 | BIO_clear_flags(ret,BIO_FLAGS_UPLINK); /* we did fopen -> we disengage UPLINK */ | ||
| 115 | BIO_set_fp(ret,file,BIO_CLOSE); | 141 | BIO_set_fp(ret,file,BIO_CLOSE); |
| 116 | return(ret); | 142 | return(ret); |
| 117 | } | 143 | } |
| @@ -123,6 +149,7 @@ BIO *BIO_new_fp(FILE *stream, int close_flag) | |||
| 123 | if ((ret=BIO_new(BIO_s_file())) == NULL) | 149 | if ((ret=BIO_new(BIO_s_file())) == NULL) |
| 124 | return(NULL); | 150 | return(NULL); |
| 125 | 151 | ||
| 152 | BIO_set_flags(ret,BIO_FLAGS_UPLINK); /* redundant, left for documentation puposes */ | ||
| 126 | BIO_set_fp(ret,stream,close_flag); | 153 | BIO_set_fp(ret,stream,close_flag); |
| 127 | return(ret); | 154 | return(ret); |
| 128 | } | 155 | } |
| @@ -137,6 +164,7 @@ static int MS_CALLBACK file_new(BIO *bi) | |||
| 137 | bi->init=0; | 164 | bi->init=0; |
| 138 | bi->num=0; | 165 | bi->num=0; |
| 139 | bi->ptr=NULL; | 166 | bi->ptr=NULL; |
| 167 | bi->flags=BIO_FLAGS_UPLINK; /* default to UPLINK */ | ||
| 140 | return(1); | 168 | return(1); |
| 141 | } | 169 | } |
| 142 | 170 | ||
| @@ -147,8 +175,12 @@ static int MS_CALLBACK file_free(BIO *a) | |||
| 147 | { | 175 | { |
| 148 | if ((a->init) && (a->ptr != NULL)) | 176 | if ((a->init) && (a->ptr != NULL)) |
| 149 | { | 177 | { |
| 150 | fclose((FILE *)a->ptr); | 178 | if (a->flags&BIO_FLAGS_UPLINK) |
| 179 | UP_fclose (a->ptr); | ||
| 180 | else | ||
| 181 | fclose (a->ptr); | ||
| 151 | a->ptr=NULL; | 182 | a->ptr=NULL; |
| 183 | a->flags=BIO_FLAGS_UPLINK; | ||
| 152 | } | 184 | } |
| 153 | a->init=0; | 185 | a->init=0; |
| 154 | } | 186 | } |
| @@ -161,8 +193,11 @@ static int MS_CALLBACK file_read(BIO *b, char *out, int outl) | |||
| 161 | 193 | ||
| 162 | if (b->init && (out != NULL)) | 194 | if (b->init && (out != NULL)) |
| 163 | { | 195 | { |
| 164 | ret=fread(out,1,(int)outl,(FILE *)b->ptr); | 196 | if (b->flags&BIO_FLAGS_UPLINK) |
| 165 | if(ret == 0 && ferror((FILE *)b->ptr)) | 197 | ret=UP_fread(out,1,(int)outl,b->ptr); |
| 198 | else | ||
| 199 | ret=fread(out,1,(int)outl,(FILE *)b->ptr); | ||
| 200 | if(ret == 0 && (b->flags&BIO_FLAGS_UPLINK)?UP_ferror((FILE *)b->ptr):ferror((FILE *)b->ptr)) | ||
| 166 | { | 201 | { |
| 167 | SYSerr(SYS_F_FREAD,get_last_sys_error()); | 202 | SYSerr(SYS_F_FREAD,get_last_sys_error()); |
| 168 | BIOerr(BIO_F_FILE_READ,ERR_R_SYS_LIB); | 203 | BIOerr(BIO_F_FILE_READ,ERR_R_SYS_LIB); |
| @@ -178,7 +213,11 @@ static int MS_CALLBACK file_write(BIO *b, const char *in, int inl) | |||
| 178 | 213 | ||
| 179 | if (b->init && (in != NULL)) | 214 | if (b->init && (in != NULL)) |
| 180 | { | 215 | { |
| 181 | if (fwrite(in,(int)inl,1,(FILE *)b->ptr)) | 216 | if (b->flags&BIO_FLAGS_UPLINK) |
| 217 | ret=UP_fwrite(in,(int)inl,1,b->ptr); | ||
| 218 | else | ||
| 219 | ret=fwrite(in,(int)inl,1,(FILE *)b->ptr); | ||
| 220 | if (ret) | ||
| 182 | ret=inl; | 221 | ret=inl; |
| 183 | /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ | 222 | /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ |
| 184 | /* according to Tim Hudson <tjh@cryptsoft.com>, the commented | 223 | /* according to Tim Hudson <tjh@cryptsoft.com>, the commented |
| @@ -199,20 +238,45 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 199 | { | 238 | { |
| 200 | case BIO_C_FILE_SEEK: | 239 | case BIO_C_FILE_SEEK: |
| 201 | case BIO_CTRL_RESET: | 240 | case BIO_CTRL_RESET: |
| 202 | ret=(long)fseek(fp,num,SEEK_SET); | 241 | if (b->flags&BIO_FLAGS_UPLINK) |
| 242 | ret=(long)UP_fseek(b->ptr,num,0); | ||
| 243 | else | ||
| 244 | ret=(long)fseek(fp,num,SEEK_SET); | ||
| 203 | break; | 245 | break; |
| 204 | case BIO_CTRL_EOF: | 246 | case BIO_CTRL_EOF: |
| 205 | ret=(long)feof(fp); | 247 | if (b->flags&BIO_FLAGS_UPLINK) |
| 248 | ret=(long)UP_feof(fp); | ||
| 249 | else | ||
| 250 | ret=(long)feof(fp); | ||
| 206 | break; | 251 | break; |
| 207 | case BIO_C_FILE_TELL: | 252 | case BIO_C_FILE_TELL: |
| 208 | case BIO_CTRL_INFO: | 253 | case BIO_CTRL_INFO: |
| 209 | ret=ftell(fp); | 254 | if (b->flags&BIO_FLAGS_UPLINK) |
| 255 | ret=UP_ftell(b->ptr); | ||
| 256 | else | ||
| 257 | ret=ftell(fp); | ||
| 210 | break; | 258 | break; |
| 211 | case BIO_C_SET_FILE_PTR: | 259 | case BIO_C_SET_FILE_PTR: |
| 212 | file_free(b); | 260 | file_free(b); |
| 213 | b->shutdown=(int)num&BIO_CLOSE; | 261 | b->shutdown=(int)num&BIO_CLOSE; |
| 214 | b->ptr=(char *)ptr; | 262 | b->ptr=ptr; |
| 215 | b->init=1; | 263 | b->init=1; |
| 264 | #if BIO_FLAGS_UPLINK!=0 | ||
| 265 | #if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES) | ||
| 266 | #define _IOB_ENTRIES 20 | ||
| 267 | #endif | ||
| 268 | #if defined(_IOB_ENTRIES) | ||
| 269 | /* Safety net to catch purely internal BIO_set_fp calls */ | ||
| 270 | if ((size_t)ptr >= (size_t)stdin && | ||
| 271 | (size_t)ptr < (size_t)(stdin+_IOB_ENTRIES)) | ||
| 272 | BIO_clear_flags(b,BIO_FLAGS_UPLINK); | ||
| 273 | #endif | ||
| 274 | #endif | ||
| 275 | #ifdef UP_fsetmode | ||
| 276 | if (b->flags&BIO_FLAGS_UPLINK) | ||
| 277 | UP_fsetmode(b->ptr,num&BIO_FP_TEXT?'t':'b'); | ||
| 278 | else | ||
| 279 | #endif | ||
| 216 | { | 280 | { |
| 217 | #if defined(OPENSSL_SYS_WINDOWS) | 281 | #if defined(OPENSSL_SYS_WINDOWS) |
| 218 | int fd = fileno((FILE*)ptr); | 282 | int fd = fileno((FILE*)ptr); |
| @@ -220,6 +284,14 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 220 | _setmode(fd,_O_TEXT); | 284 | _setmode(fd,_O_TEXT); |
| 221 | else | 285 | else |
| 222 | _setmode(fd,_O_BINARY); | 286 | _setmode(fd,_O_BINARY); |
| 287 | #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
| 288 | int fd = fileno((FILE*)ptr); | ||
| 289 | /* Under CLib there are differences in file modes | ||
| 290 | */ | ||
| 291 | if (num & BIO_FP_TEXT) | ||
| 292 | setmode(fd,O_TEXT); | ||
| 293 | else | ||
| 294 | setmode(fd,O_BINARY); | ||
| 223 | #elif defined(OPENSSL_SYS_MSDOS) | 295 | #elif defined(OPENSSL_SYS_MSDOS) |
| 224 | int fd = fileno((FILE*)ptr); | 296 | int fd = fileno((FILE*)ptr); |
| 225 | /* Set correct text/binary mode */ | 297 | /* Set correct text/binary mode */ |
| @@ -272,6 +344,12 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 272 | else | 344 | else |
| 273 | strcat(p,"t"); | 345 | strcat(p,"t"); |
| 274 | #endif | 346 | #endif |
| 347 | #if defined(OPENSSL_SYS_NETWARE) | ||
| 348 | if (!(num & BIO_FP_TEXT)) | ||
| 349 | strcat(p,"b"); | ||
| 350 | else | ||
| 351 | strcat(p,"t"); | ||
| 352 | #endif | ||
| 275 | fp=fopen(ptr,p); | 353 | fp=fopen(ptr,p); |
| 276 | if (fp == NULL) | 354 | if (fp == NULL) |
| 277 | { | 355 | { |
| @@ -281,8 +359,9 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 281 | ret=0; | 359 | ret=0; |
| 282 | break; | 360 | break; |
| 283 | } | 361 | } |
| 284 | b->ptr=(char *)fp; | 362 | b->ptr=fp; |
| 285 | b->init=1; | 363 | b->init=1; |
| 364 | BIO_clear_flags(b,BIO_FLAGS_UPLINK); /* we did fopen -> we disengage UPLINK */ | ||
| 286 | break; | 365 | break; |
| 287 | case BIO_C_GET_FILE_PTR: | 366 | case BIO_C_GET_FILE_PTR: |
| 288 | /* the ptr parameter is actually a FILE ** in this case. */ | 367 | /* the ptr parameter is actually a FILE ** in this case. */ |
| @@ -299,7 +378,10 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 299 | b->shutdown=(int)num; | 378 | b->shutdown=(int)num; |
| 300 | break; | 379 | break; |
| 301 | case BIO_CTRL_FLUSH: | 380 | case BIO_CTRL_FLUSH: |
| 302 | fflush((FILE *)b->ptr); | 381 | if (b->flags&BIO_FLAGS_UPLINK) |
| 382 | UP_fflush(b->ptr); | ||
| 383 | else | ||
| 384 | fflush((FILE *)b->ptr); | ||
| 303 | break; | 385 | break; |
| 304 | case BIO_CTRL_DUP: | 386 | case BIO_CTRL_DUP: |
| 305 | ret=1; | 387 | ret=1; |
| @@ -321,7 +403,10 @@ static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size) | |||
| 321 | int ret=0; | 403 | int ret=0; |
| 322 | 404 | ||
| 323 | buf[0]='\0'; | 405 | buf[0]='\0'; |
| 324 | fgets(buf,size,(FILE *)bp->ptr); | 406 | if (bp->flags&BIO_FLAGS_UPLINK) |
| 407 | UP_fgets(buf,size,bp->ptr); | ||
| 408 | else | ||
| 409 | fgets(buf,size,(FILE *)bp->ptr); | ||
| 325 | if (buf[0] != '\0') | 410 | if (buf[0] != '\0') |
| 326 | ret=strlen(buf); | 411 | ret=strlen(buf); |
| 327 | return(ret); | 412 | return(ret); |
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 1eb678cac0..6360dbc820 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
| @@ -78,6 +78,8 @@ | |||
| 78 | # include <starlet.h> | 78 | # include <starlet.h> |
| 79 | #elif defined(__ultrix) | 79 | #elif defined(__ultrix) |
| 80 | # include <sys/syslog.h> | 80 | # include <sys/syslog.h> |
| 81 | #elif defined(OPENSSL_SYS_NETWARE) | ||
| 82 | # define NO_SYSLOG | ||
| 81 | #elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) | 83 | #elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) |
| 82 | # include <syslog.h> | 84 | # include <syslog.h> |
| 83 | #endif | 85 | #endif |
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c index 2c1c405ec7..472dd75821 100644 --- a/src/lib/libcrypto/bio/bss_sock.c +++ b/src/lib/libcrypto/bio/bss_sock.c | |||
| @@ -56,8 +56,6 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef OPENSSL_NO_SOCK | ||
| 60 | |||
| 61 | #include <stdio.h> | 59 | #include <stdio.h> |
| 62 | #include <errno.h> | 60 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 61 | #define USE_SOCKETS |
| @@ -248,7 +246,7 @@ int BIO_sock_non_fatal_error(int err) | |||
| 248 | { | 246 | { |
| 249 | switch (err) | 247 | switch (err) |
| 250 | { | 248 | { |
| 251 | #if defined(OPENSSL_SYS_WINDOWS) | 249 | #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE) |
| 252 | # if defined(WSAEWOULDBLOCK) | 250 | # if defined(WSAEWOULDBLOCK) |
| 253 | case WSAEWOULDBLOCK: | 251 | case WSAEWOULDBLOCK: |
| 254 | # endif | 252 | # endif |
| @@ -279,7 +277,7 @@ int BIO_sock_non_fatal_error(int err) | |||
| 279 | #endif | 277 | #endif |
| 280 | 278 | ||
| 281 | #ifdef EAGAIN | 279 | #ifdef EAGAIN |
| 282 | #if EWOULDBLOCK != EAGAIN | 280 | # if EWOULDBLOCK != EAGAIN |
| 283 | case EAGAIN: | 281 | case EAGAIN: |
| 284 | # endif | 282 | # endif |
| 285 | #endif | 283 | #endif |
| @@ -302,4 +300,3 @@ int BIO_sock_non_fatal_error(int err) | |||
| 302 | } | 300 | } |
| 303 | return(0); | 301 | return(0); |
| 304 | } | 302 | } |
| 305 | #endif | ||
