summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r--src/lib/libcrypto/bio/b_print.c29
-rw-r--r--src/lib/libcrypto/bio/b_sock.c16
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c2
-rw-r--r--src/lib/libcrypto/bio/bio.h7
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c15
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c3
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c4
-rw-r--r--src/lib/libcrypto/bio/bss_file.c2
-rw-r--r--src/lib/libcrypto/bio/bss_log.c13
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c8
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c6
11 files changed, 78 insertions, 27 deletions
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 80c9cb69db..a9e552f245 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -378,7 +378,7 @@ _dopr(
378 case 'p': 378 case 'p':
379 value = (long)va_arg(args, void *); 379 value = (long)va_arg(args, void *);
380 fmtint(sbuffer, buffer, &currlen, maxlen, 380 fmtint(sbuffer, buffer, &currlen, maxlen,
381 value, 16, min, max, flags); 381 value, 16, min, max, flags|DP_F_NUM);
382 break; 382 break;
383 case 'n': /* XXX */ 383 case 'n': /* XXX */
384 if (cflags == DP_C_SHORT) { 384 if (cflags == DP_C_SHORT) {
@@ -482,8 +482,9 @@ fmtint(
482 int flags) 482 int flags)
483{ 483{
484 int signvalue = 0; 484 int signvalue = 0;
485 char *prefix = "";
485 unsigned LLONG uvalue; 486 unsigned LLONG uvalue;
486 char convert[20]; 487 char convert[DECIMAL_SIZE(value)+3];
487 int place = 0; 488 int place = 0;
488 int spadlen = 0; 489 int spadlen = 0;
489 int zpadlen = 0; 490 int zpadlen = 0;
@@ -501,6 +502,10 @@ fmtint(
501 else if (flags & DP_F_SPACE) 502 else if (flags & DP_F_SPACE)
502 signvalue = ' '; 503 signvalue = ' ';
503 } 504 }
505 if (flags & DP_F_NUM) {
506 if (base == 8) prefix = "0";
507 if (base == 16) prefix = "0x";
508 }
504 if (flags & DP_F_UP) 509 if (flags & DP_F_UP)
505 caps = 1; 510 caps = 1;
506 do { 511 do {
@@ -508,13 +513,13 @@ fmtint(
508 (caps ? "0123456789ABCDEF" : "0123456789abcdef") 513 (caps ? "0123456789ABCDEF" : "0123456789abcdef")
509 [uvalue % (unsigned) base]; 514 [uvalue % (unsigned) base];
510 uvalue = (uvalue / (unsigned) base); 515 uvalue = (uvalue / (unsigned) base);
511 } while (uvalue && (place < 20)); 516 } while (uvalue && (place < sizeof convert));
512 if (place == 20) 517 if (place == sizeof convert)
513 place--; 518 place--;
514 convert[place] = 0; 519 convert[place] = 0;
515 520
516 zpadlen = max - place; 521 zpadlen = max - place;
517 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0); 522 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix);
518 if (zpadlen < 0) 523 if (zpadlen < 0)
519 zpadlen = 0; 524 zpadlen = 0;
520 if (spadlen < 0) 525 if (spadlen < 0)
@@ -536,6 +541,12 @@ fmtint(
536 if (signvalue) 541 if (signvalue)
537 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); 542 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
538 543
544 /* prefix */
545 while (*prefix) {
546 doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
547 prefix++;
548 }
549
539 /* zeros */ 550 /* zeros */
540 if (zpadlen > 0) { 551 if (zpadlen > 0) {
541 while (zpadlen > 0) { 552 while (zpadlen > 0) {
@@ -641,8 +652,8 @@ fmtfp(
641 (caps ? "0123456789ABCDEF" 652 (caps ? "0123456789ABCDEF"
642 : "0123456789abcdef")[intpart % 10]; 653 : "0123456789abcdef")[intpart % 10];
643 intpart = (intpart / 10); 654 intpart = (intpart / 10);
644 } while (intpart && (iplace < 20)); 655 } while (intpart && (iplace < sizeof iplace));
645 if (iplace == 20) 656 if (iplace == sizeof iplace)
646 iplace--; 657 iplace--;
647 iconvert[iplace] = 0; 658 iconvert[iplace] = 0;
648 659
@@ -653,7 +664,7 @@ fmtfp(
653 : "0123456789abcdef")[fracpart % 10]; 664 : "0123456789abcdef")[fracpart % 10];
654 fracpart = (fracpart / 10); 665 fracpart = (fracpart / 10);
655 } while (fplace < max); 666 } while (fplace < max);
656 if (fplace == 20) 667 if (fplace == sizeof fplace)
657 fplace--; 668 fplace--;
658 fconvert[fplace] = 0; 669 fconvert[fplace] = 0;
659 670
@@ -692,7 +703,7 @@ fmtfp(
692 * Decimal point. This should probably use locale to find the correct 703 * Decimal point. This should probably use locale to find the correct
693 * char to print out. 704 * char to print out.
694 */ 705 */
695 if (max > 0) { 706 if (max > 0 || (flags & DP_F_NUM)) {
696 doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); 707 doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
697 708
698 while (fplace > 0) 709 while (fplace > 0)
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 45bd7c47e8..601a14f37c 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -83,6 +83,7 @@
83static int wsa_init_done=0; 83static int wsa_init_done=0;
84#endif 84#endif
85 85
86#if 0
86static unsigned long BIO_ghbn_hits=0L; 87static unsigned long BIO_ghbn_hits=0L;
87static unsigned long BIO_ghbn_miss=0L; 88static unsigned long BIO_ghbn_miss=0L;
88 89
@@ -93,6 +94,7 @@ static struct ghbn_cache_st
93 struct hostent *ent; 94 struct hostent *ent;
94 unsigned long order; 95 unsigned long order;
95 } ghbn_cache[GHBN_NUM]; 96 } ghbn_cache[GHBN_NUM];
97#endif
96 98
97static int get_ip(const char *str,unsigned char *ip); 99static int get_ip(const char *str,unsigned char *ip);
98#if 0 100#if 0
@@ -230,6 +232,7 @@ int BIO_sock_error(int sock)
230 return(j); 232 return(j);
231 } 233 }
232 234
235#if 0
233long BIO_ghbn_ctrl(int cmd, int iarg, char *parg) 236long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
234 { 237 {
235 int i; 238 int i;
@@ -267,6 +270,7 @@ long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
267 } 270 }
268 return(1); 271 return(1);
269 } 272 }
273#endif
270 274
271#if 0 275#if 0
272static struct hostent *ghbn_dup(struct hostent *a) 276static struct hostent *ghbn_dup(struct hostent *a)
@@ -463,6 +467,12 @@ int BIO_sock_init(void)
463 } 467 }
464 } 468 }
465#endif /* OPENSSL_SYS_WINDOWS */ 469#endif /* OPENSSL_SYS_WINDOWS */
470#ifdef WATT32
471 extern int _watt_do_exit;
472 _watt_do_exit = 0; /* don't make sock_init() call exit() */
473 if (sock_init())
474 return (-1);
475#endif
466 return(1); 476 return(1);
467 } 477 }
468 478
@@ -472,7 +482,9 @@ void BIO_sock_cleanup(void)
472 if (wsa_init_done) 482 if (wsa_init_done)
473 { 483 {
474 wsa_init_done=0; 484 wsa_init_done=0;
485#ifndef OPENSSL_SYS_WINCE
475 WSACancelBlockingCall(); 486 WSACancelBlockingCall();
487#endif
476 WSACleanup(); 488 WSACleanup();
477 } 489 }
478#endif 490#endif
@@ -480,7 +492,7 @@ void BIO_sock_cleanup(void)
480 492
481#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000 493#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000
482 494
483int BIO_socket_ioctl(int fd, long type, unsigned long *arg) 495int BIO_socket_ioctl(int fd, long type, void *arg)
484 { 496 {
485 int i; 497 int i;
486 498
@@ -730,7 +742,7 @@ int BIO_set_tcp_ndelay(int s, int on)
730int BIO_socket_nbio(int s, int mode) 742int BIO_socket_nbio(int s, int mode)
731 { 743 {
732 int ret= -1; 744 int ret= -1;
733 unsigned long l; 745 int l;
734 746
735 l=mode; 747 l=mode;
736#ifdef FIONBIO 748#ifdef FIONBIO
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index 6ccda06596..1cecd70579 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -482,7 +482,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
482 size-=i; 482 size-=i;
483 ctx->ibuf_len-=i; 483 ctx->ibuf_len-=i;
484 ctx->ibuf_off+=i; 484 ctx->ibuf_off+=i;
485 if ((flag) || (i == size)) 485 if (flag || size == 0)
486 { 486 {
487 *buf='\0'; 487 *buf='\0';
488 return(num); 488 return(num);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index c5caf253c9..fbbc16d00c 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -244,7 +244,7 @@ typedef struct bio_method_st
244 long (_far *ctrl)(); 244 long (_far *ctrl)();
245 int (_far *create)(); 245 int (_far *create)();
246 int (_far *destroy)(); 246 int (_far *destroy)();
247 long (_fat *callback_ctrl)(); 247 long (_far *callback_ctrl)();
248 } BIO_METHOD; 248 } BIO_METHOD;
249#endif 249#endif
250 250
@@ -522,6 +522,7 @@ int BIO_read(BIO *b, void *data, int len);
522int BIO_gets(BIO *bp,char *buf, int size); 522int BIO_gets(BIO *bp,char *buf, int size);
523int BIO_write(BIO *b, const void *data, int len); 523int BIO_write(BIO *b, const void *data, int len);
524int BIO_puts(BIO *bp,const char *buf); 524int BIO_puts(BIO *bp,const char *buf);
525int BIO_indent(BIO *b,int indent,int max);
525long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); 526long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
526long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); 527long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
527char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); 528char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
@@ -584,7 +585,7 @@ struct hostent *BIO_gethostbyname(const char *name);
584 * and an appropriate error code is set). 585 * and an appropriate error code is set).
585 */ 586 */
586int BIO_sock_error(int sock); 587int BIO_sock_error(int sock);
587int BIO_socket_ioctl(int fd, long type, unsigned long *arg); 588int BIO_socket_ioctl(int fd, long type, void *arg);
588int BIO_socket_nbio(int fd,int mode); 589int BIO_socket_nbio(int fd,int mode);
589int BIO_get_port(const char *str, unsigned short *port_ptr); 590int BIO_get_port(const char *str, unsigned short *port_ptr);
590int BIO_get_host_ip(const char *str, unsigned char *ip); 591int BIO_get_host_ip(const char *str, unsigned char *ip);
@@ -608,7 +609,7 @@ int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
608 609
609void BIO_copy_next_retry(BIO *b); 610void BIO_copy_next_retry(BIO *b);
610 611
611long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); 612/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
612 613
613int BIO_printf(BIO *bio, const char *format, ...); 614int BIO_printf(BIO *bio, const char *format, ...);
614int BIO_vprintf(BIO *bio, const char *format, va_list args); 615int BIO_vprintf(BIO *bio, const char *format, va_list args);
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 50df2238fa..692c8fb5c6 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -272,6 +272,18 @@ int BIO_gets(BIO *b, char *in, int inl)
272 return(i); 272 return(i);
273 } 273 }
274 274
275int BIO_indent(BIO *b,int indent,int max)
276 {
277 if(indent < 0)
278 indent=0;
279 if(indent > max)
280 indent=max;
281 while(indent--)
282 if(BIO_puts(b," ") != 1)
283 return 0;
284 return 1;
285 }
286
275long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) 287long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg)
276 { 288 {
277 int i; 289 int i;
@@ -383,6 +395,8 @@ BIO *BIO_pop(BIO *b)
383 if (b == NULL) return(NULL); 395 if (b == NULL) return(NULL);
384 ret=b->next_bio; 396 ret=b->next_bio;
385 397
398 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
399
386 if (b->prev_bio != NULL) 400 if (b->prev_bio != NULL)
387 b->prev_bio->next_bio=b->next_bio; 401 b->prev_bio->next_bio=b->next_bio;
388 if (b->next_bio != NULL) 402 if (b->next_bio != NULL)
@@ -390,7 +404,6 @@ BIO *BIO_pop(BIO *b)
390 404
391 b->next_bio=NULL; 405 b->next_bio=NULL;
392 b->prev_bio=NULL; 406 b->prev_bio=NULL;
393 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
394 return(ret); 407 return(ret);
395 } 408 }
396 409
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 1c485a4479..aa58dab046 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -28,13 +28,12 @@
28 28
29#include <openssl/bio.h> 29#include <openssl/bio.h>
30#include <openssl/err.h> 30#include <openssl/err.h>
31#include <openssl/err.h>
32#include <openssl/crypto.h> 31#include <openssl/crypto.h>
33 32
34#include "e_os.h" 33#include "e_os.h"
35 34
36/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */ 35/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
37#if defined(OPENSSL_SYS_VSWORKS) 36#if defined(OPENSSL_SYS_VXWORKS)
38# undef SSIZE_MAX 37# undef SSIZE_MAX
39#endif 38#endif
40#ifndef SSIZE_MAX 39#ifndef SSIZE_MAX
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index f91ae4c8c6..743db6ff94 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -519,7 +519,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
519 else if (num == 2) 519 else if (num == 2)
520 { 520 {
521 char buf[16]; 521 char buf[16];
522 char *p = ptr; 522 unsigned char *p = ptr;
523 523
524 sprintf(buf,"%d.%d.%d.%d", 524 sprintf(buf,"%d.%d.%d.%d",
525 p[0],p[1],p[2],p[3]); 525 p[0],p[1],p[2],p[3]);
@@ -530,7 +530,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
530 } 530 }
531 else if (num == 3) 531 else if (num == 3)
532 { 532 {
533 char buf[16]; 533 char buf[DECIMAL_SIZE(int)+1];
534 534
535 sprintf(buf,"%d",*(int *)ptr); 535 sprintf(buf,"%d",*(int *)ptr);
536 if (data->param_port != NULL) 536 if (data->param_port != NULL)
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 826b361fa2..a66600c1a3 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -247,7 +247,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
247 ret=0; 247 ret=0;
248 break; 248 break;
249 } 249 }
250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) 250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2)
251 if (!(num & BIO_FP_TEXT)) 251 if (!(num & BIO_FP_TEXT))
252 strcat(p,"b"); 252 strcat(p,"b");
253 else 253 else
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index a39d95297c..1eb678cac0 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -68,7 +68,8 @@
68 68
69#include "cryptlib.h" 69#include "cryptlib.h"
70 70
71#if defined(OPENSSL_SYS_WIN32) 71#if defined(OPENSSL_SYS_WINCE)
72#elif defined(OPENSSL_SYS_WIN32)
72# include <process.h> 73# include <process.h>
73#elif defined(OPENSSL_SYS_VMS) 74#elif defined(OPENSSL_SYS_VMS)
74# include <opcdef.h> 75# include <opcdef.h>
@@ -77,7 +78,7 @@
77# include <starlet.h> 78# include <starlet.h>
78#elif defined(__ultrix) 79#elif defined(__ultrix)
79# include <sys/syslog.h> 80# include <sys/syslog.h>
80#elif !defined(MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) /* Unix */ 81#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
81# include <syslog.h> 82# include <syslog.h>
82#endif 83#endif
83 84
@@ -274,7 +275,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
274 LPCSTR lpszStrings[2]; 275 LPCSTR lpszStrings[2];
275 WORD evtype= EVENTLOG_ERROR_TYPE; 276 WORD evtype= EVENTLOG_ERROR_TYPE;
276 int pid = _getpid(); 277 int pid = _getpid();
277 char pidbuf[20]; 278 char pidbuf[DECIMAL_SIZE(pid)+4];
278 279
279 switch (priority) 280 switch (priority)
280 { 281 {
@@ -373,11 +374,15 @@ static void xcloselog(BIO* bp)
373{ 374{
374} 375}
375 376
376#else /* Unix */ 377#else /* Unix/Watt32 */
377 378
378static void xopenlog(BIO* bp, char* name, int level) 379static void xopenlog(BIO* bp, char* name, int level)
379{ 380{
381#ifdef WATT32 /* djgpp/DOS */
382 openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level);
383#else
380 openlog(name, LOG_PID|LOG_CONS, level); 384 openlog(name, LOG_PID|LOG_CONS, level);
385#endif
381} 386}
382 387
383static void xsyslog(BIO *bp, int priority, const char *string) 388static void xsyslog(BIO *bp, int priority, const char *string)
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index 28ff7582bf..a4edb711ae 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -190,7 +190,7 @@ static int mem_write(BIO *b, const char *in, int inl)
190 190
191 BIO_clear_retry_flags(b); 191 BIO_clear_retry_flags(b);
192 blen=bm->length; 192 blen=bm->length;
193 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl)) 193 if (BUF_MEM_grow_clean(bm,blen+inl) != (blen+inl))
194 goto end; 194 goto end;
195 memcpy(&(bm->data[blen]),in,inl); 195 memcpy(&(bm->data[blen]),in,inl);
196 ret=inl; 196 ret=inl;
@@ -284,7 +284,11 @@ static int mem_gets(BIO *bp, char *buf, int size)
284 284
285 BIO_clear_retry_flags(bp); 285 BIO_clear_retry_flags(bp);
286 j=bm->length; 286 j=bm->length;
287 if (j <= 0) return(0); 287 if (j <= 0)
288 {
289 *buf='\0';
290 return 0;
291 }
288 p=bm->data; 292 p=bm->data;
289 for (i=0; i<j; i++) 293 for (i=0; i<j; i++)
290 { 294 {
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index fdabd16d7e..2c1c405ec7 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -64,6 +64,12 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WATT32
68#define sock_write SockWrite /* Watt-32 uses same names */
69#define sock_read SockRead
70#define sock_puts SockPuts
71#endif
72
67static int sock_write(BIO *h, const char *buf, int num); 73static int sock_write(BIO *h, const char *buf, int num);
68static int sock_read(BIO *h, char *buf, int size); 74static int sock_read(BIO *h, char *buf, int size);
69static int sock_puts(BIO *h, const char *str); 75static int sock_puts(BIO *h, const char *str);