diff options
Diffstat (limited to 'src/lib/libssl/s23_pkt.c')
-rw-r--r-- | src/lib/libssl/s23_pkt.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/src/lib/libssl/s23_pkt.c b/src/lib/libssl/s23_pkt.c index eba8d9d8fc..28d07a2212 100644 --- a/src/lib/libssl/s23_pkt.c +++ b/src/lib/libssl/s23_pkt.c | |||
@@ -62,55 +62,53 @@ | |||
62 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
63 | #include <openssl/buffer.h> | 63 | #include <openssl/buffer.h> |
64 | 64 | ||
65 | int ssl23_write_bytes(SSL *s) | 65 | int |
66 | { | 66 | ssl23_write_bytes(SSL *s) |
67 | int i,num,tot; | 67 | { |
68 | int i, num, tot; | ||
68 | char *buf; | 69 | char *buf; |
69 | 70 | ||
70 | buf=s->init_buf->data; | 71 | buf = s->init_buf->data; |
71 | tot=s->init_off; | 72 | tot = s->init_off; |
72 | num=s->init_num; | 73 | num = s->init_num; |
73 | for (;;) | 74 | for (;;) { |
74 | { | 75 | s->rwstate = SSL_WRITING; |
75 | s->rwstate=SSL_WRITING; | 76 | i = BIO_write(s->wbio, &(buf[tot]), num); |
76 | i=BIO_write(s->wbio,&(buf[tot]),num); | 77 | if (i <= 0) { |
77 | if (i <= 0) | 78 | s->init_off = tot; |
78 | { | 79 | s->init_num = num; |
79 | s->init_off=tot; | 80 | return (i); |
80 | s->init_num=num; | ||
81 | return(i); | ||
82 | } | ||
83 | s->rwstate=SSL_NOTHING; | ||
84 | if (i == num) return(tot+i); | ||
85 | |||
86 | num-=i; | ||
87 | tot+=i; | ||
88 | } | 81 | } |
82 | s->rwstate = SSL_NOTHING; | ||
83 | if (i == num) | ||
84 | return (tot + i); | ||
85 | |||
86 | num -= i; | ||
87 | tot += i; | ||
89 | } | 88 | } |
89 | } | ||
90 | 90 | ||
91 | /* return regularly only when we have read (at least) 'n' bytes */ | 91 | /* return regularly only when we have read (at least) 'n' bytes */ |
92 | int ssl23_read_bytes(SSL *s, int n) | 92 | int |
93 | { | 93 | ssl23_read_bytes(SSL *s, int n) |
94 | { | ||
94 | unsigned char *p; | 95 | unsigned char *p; |
95 | int j; | 96 | int j; |
96 | 97 | ||
97 | if (s->packet_length < (unsigned int)n) | 98 | if (s->packet_length < (unsigned int)n) { |
98 | { | 99 | p = s->packet; |
99 | p=s->packet; | ||
100 | 100 | ||
101 | for (;;) | 101 | for (;;) { |
102 | { | 102 | s->rwstate = SSL_READING; |
103 | s->rwstate=SSL_READING; | 103 | j = BIO_read(s->rbio,(char *)&(p[s->packet_length]), |
104 | j=BIO_read(s->rbio,(char *)&(p[s->packet_length]), | 104 | n - s->packet_length); |
105 | n-s->packet_length); | ||
106 | if (j <= 0) | 105 | if (j <= 0) |
107 | return(j); | 106 | return (j); |
108 | s->rwstate=SSL_NOTHING; | 107 | s->rwstate = SSL_NOTHING; |
109 | s->packet_length+=j; | 108 | s->packet_length += j; |
110 | if (s->packet_length >= (unsigned int)n) | 109 | if (s->packet_length >= (unsigned int)n) |
111 | return(s->packet_length); | 110 | return (s->packet_length); |
112 | } | ||
113 | } | 111 | } |
114 | return(n); | ||
115 | } | 112 | } |
116 | 113 | return (n); | |
114 | } | ||