mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-20 20:23:38 +08:00
update
This commit is contained in:
@@ -73,6 +73,8 @@ tests:
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,14 +49,14 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Stolen from tjh's ssl/ssl_trc.c stuff.
|
||||
*/
|
||||
|
||||
@@ -65,123 +65,145 @@
|
||||
#include "bio_lcl.h"
|
||||
|
||||
#define TRUNCATE
|
||||
#define DUMP_WIDTH 16
|
||||
#define DUMP_WIDTH 16
|
||||
#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4))
|
||||
|
||||
int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len)
|
||||
{
|
||||
return BIO_dump_indent_cb(cb, u, s, len, 0);
|
||||
}
|
||||
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len)
|
||||
{
|
||||
return BIO_dump_indent_cb(cb, u, s, len, 0);
|
||||
}
|
||||
|
||||
int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len, int indent)
|
||||
{
|
||||
int ret=0;
|
||||
char buf[288+1],tmp[20],str[128+1];
|
||||
int i,j,rows,trc;
|
||||
unsigned char ch;
|
||||
int dump_width;
|
||||
int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
|
||||
void *u, const char *s, int len, int indent)
|
||||
{
|
||||
int ret = 0;
|
||||
char buf[288 + 1], tmp[20], str[128 + 1];
|
||||
int i, j, rows, trc;
|
||||
unsigned char ch;
|
||||
int dump_width;
|
||||
|
||||
trc=0;
|
||||
trc = 0;
|
||||
|
||||
#ifdef TRUNCATE
|
||||
for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
|
||||
trc++;
|
||||
for (; (len > 0) && ((s[len - 1] == ' ') || (s[len - 1] == '\0')); len--)
|
||||
trc++;
|
||||
#endif
|
||||
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
if (indent)
|
||||
{
|
||||
if (indent > 128) indent=128;
|
||||
memset(str,' ',indent);
|
||||
}
|
||||
str[indent]='\0';
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
if (indent) {
|
||||
if (indent > 128)
|
||||
indent = 128;
|
||||
memset(str, ' ', indent);
|
||||
}
|
||||
str[indent] = '\0';
|
||||
|
||||
dump_width=DUMP_WIDTH_LESS_INDENT(indent);
|
||||
rows=(len/dump_width);
|
||||
if ((rows*dump_width)<len)
|
||||
rows++;
|
||||
for(i=0;i<rows;i++)
|
||||
{
|
||||
buf[0]='\0'; /* start with empty string */
|
||||
BUF_strlcpy(buf,str,sizeof buf);
|
||||
BIO_snprintf(tmp,sizeof tmp,"%04x - ",i*dump_width);
|
||||
BUF_strlcat(buf,tmp,sizeof buf);
|
||||
for(j=0;j<dump_width;j++)
|
||||
{
|
||||
if (((i*dump_width)+j)>=len)
|
||||
{
|
||||
BUF_strlcat(buf," ",sizeof buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||
BIO_snprintf(tmp,sizeof tmp,"%02x%c",ch,
|
||||
j==7?'-':' ');
|
||||
BUF_strlcat(buf,tmp,sizeof buf);
|
||||
}
|
||||
}
|
||||
BUF_strlcat(buf," ",sizeof buf);
|
||||
for(j=0;j<dump_width;j++)
|
||||
{
|
||||
if (((i*dump_width)+j)>=len)
|
||||
break;
|
||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||
dump_width = DUMP_WIDTH_LESS_INDENT(indent);
|
||||
rows = (len / dump_width);
|
||||
if ((rows * dump_width) < len)
|
||||
rows++;
|
||||
for (i = 0; i < rows; i++) {
|
||||
buf[0] = '\0'; /* start with empty string */
|
||||
BUF_strlcpy(buf, str, sizeof buf);
|
||||
BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
|
||||
BUF_strlcat(buf, tmp, sizeof buf);
|
||||
for (j = 0; j < dump_width; j++) {
|
||||
if (((i * dump_width) + j) >= len) {
|
||||
BUF_strlcat(buf, " ", sizeof buf);
|
||||
} else {
|
||||
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
|
||||
BIO_snprintf(tmp, sizeof tmp, "%02x%c", ch,
|
||||
j == 7 ? '-' : ' ');
|
||||
BUF_strlcat(buf, tmp, sizeof buf);
|
||||
}
|
||||
}
|
||||
BUF_strlcat(buf, " ", sizeof buf);
|
||||
for (j = 0; j < dump_width; j++) {
|
||||
if (((i * dump_width) + j) >= len)
|
||||
break;
|
||||
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
|
||||
#ifndef CHARSET_EBCDIC
|
||||
BIO_snprintf(tmp,sizeof tmp,"%c",
|
||||
((ch>=' ')&&(ch<='~'))?ch:'.');
|
||||
BIO_snprintf(tmp, sizeof tmp, "%c",
|
||||
((ch >= ' ') && (ch <= '~')) ? ch : '.');
|
||||
#else
|
||||
BIO_snprintf(tmp,sizeof tmp,"%c",
|
||||
((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
|
||||
? os_toebcdic[ch]
|
||||
: '.');
|
||||
BIO_snprintf(tmp, sizeof tmp, "%c",
|
||||
((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
|
||||
? os_toebcdic[ch]
|
||||
: '.');
|
||||
#endif
|
||||
BUF_strlcat(buf,tmp,sizeof buf);
|
||||
}
|
||||
BUF_strlcat(buf,"\n",sizeof buf);
|
||||
/* if this is the last call then update the ddt_dump thing so
|
||||
* that we will move the selection point in the debug window
|
||||
*/
|
||||
ret+=cb((void *)buf,strlen(buf),u);
|
||||
}
|
||||
BUF_strlcat(buf, tmp, sizeof buf);
|
||||
}
|
||||
BUF_strlcat(buf, "\n", sizeof buf);
|
||||
/*
|
||||
* if this is the last call then update the ddt_dump thing so that we
|
||||
* will move the selection point in the debug window
|
||||
*/
|
||||
ret += cb((void *)buf, strlen(buf), u);
|
||||
}
|
||||
#ifdef TRUNCATE
|
||||
if (trc > 0)
|
||||
{
|
||||
BIO_snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str,
|
||||
len+trc);
|
||||
ret+=cb((void *)buf,strlen(buf),u);
|
||||
}
|
||||
if (trc > 0) {
|
||||
BIO_snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", str,
|
||||
len + trc);
|
||||
ret += cb((void *)buf, strlen(buf), u);
|
||||
}
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
static int write_fp(const void *data, size_t len, void *fp)
|
||||
{
|
||||
return UP_fwrite(data, len, 1, fp);
|
||||
}
|
||||
{
|
||||
return UP_fwrite(data, len, 1, fp);
|
||||
}
|
||||
|
||||
int BIO_dump_fp(FILE *fp, const char *s, int len)
|
||||
{
|
||||
return BIO_dump_cb(write_fp, fp, s, len);
|
||||
}
|
||||
{
|
||||
return BIO_dump_cb(write_fp, fp, s, len);
|
||||
}
|
||||
|
||||
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent)
|
||||
{
|
||||
return BIO_dump_indent_cb(write_fp, fp, s, len, indent);
|
||||
}
|
||||
{
|
||||
return BIO_dump_indent_cb(write_fp, fp, s, len, indent);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int write_bio(const void *data, size_t len, void *bp)
|
||||
{
|
||||
return BIO_write((BIO *)bp, (const char *)data, len);
|
||||
}
|
||||
int BIO_dump(BIO *bp, const char *s, int len)
|
||||
{
|
||||
return BIO_dump_cb(write_bio, bp, s, len);
|
||||
}
|
||||
int BIO_dump_indent(BIO *bp, const char *s, int len, int indent)
|
||||
{
|
||||
return BIO_dump_indent_cb(write_bio, bp, s, len, indent);
|
||||
}
|
||||
{
|
||||
return BIO_write((BIO *)bp, (const char *)data, len);
|
||||
}
|
||||
|
||||
int BIO_dump(BIO *bp, const char *s, int len)
|
||||
{
|
||||
return BIO_dump_cb(write_bio, bp, s, len);
|
||||
}
|
||||
|
||||
int BIO_dump_indent(BIO *bp, const char *s, int len, int indent)
|
||||
{
|
||||
return BIO_dump_indent_cb(write_bio, bp, s, len, indent);
|
||||
}
|
||||
|
||||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||
int datalen)
|
||||
{
|
||||
int i, j = 0;
|
||||
|
||||
if (datalen < 1)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < datalen - 1; i++) {
|
||||
if (i && !j)
|
||||
BIO_printf(out, "%*s", indent, "");
|
||||
|
||||
BIO_printf(out, "%02X:", data[i]);
|
||||
|
||||
j = (j + 1) % width;
|
||||
if (!j)
|
||||
BIO_printf(out, "\n");
|
||||
}
|
||||
|
||||
if (i && !j)
|
||||
BIO_printf(out, "%*s", indent, "");
|
||||
BIO_printf(out, "%02X", data[datalen - 1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -63,7 +63,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
* Stolen from tjh's ssl/ssl_trc.c stuff.
|
||||
*/
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#ifndef NO_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#include <openssl/bn.h> /* To get BN_LLONG properly defined */
|
||||
#include <openssl/bio.h>
|
||||
@@ -94,7 +94,7 @@
|
||||
* on all source code distributions.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*-
|
||||
* This code contains numerious changes and enhancements which were
|
||||
* made by lots of contributors over the last years to Patrick Powell's
|
||||
* original code:
|
||||
@@ -110,31 +110,31 @@
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#define LDOUBLE long double
|
||||
# define LDOUBLE long double
|
||||
#else
|
||||
#define LDOUBLE double
|
||||
# define LDOUBLE double
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define LLONG __int64
|
||||
# define LLONG __int64
|
||||
# else
|
||||
# define LLONG long long
|
||||
# define LLONG long long
|
||||
# endif
|
||||
#else
|
||||
#define LLONG long
|
||||
# define LLONG long
|
||||
#endif
|
||||
|
||||
static void fmtstr (char **, char **, size_t *, size_t *,
|
||||
const char *, int, int, int);
|
||||
static void fmtint (char **, char **, size_t *, size_t *,
|
||||
LLONG, int, int, int, int);
|
||||
static void fmtfp (char **, char **, size_t *, size_t *,
|
||||
LDOUBLE, int, int, int);
|
||||
static void doapr_outch (char **, char **, size_t *, size_t *, int);
|
||||
static void fmtstr(char **, char **, size_t *, size_t *,
|
||||
const char *, int, int, int);
|
||||
static void fmtint(char **, char **, size_t *, size_t *,
|
||||
LLONG, int, int, int, int);
|
||||
static void fmtfp(char **, char **, size_t *, size_t *,
|
||||
LDOUBLE, int, int, int);
|
||||
static void doapr_outch(char **, char **, size_t *, size_t *, int);
|
||||
static void _dopr(char **sbuffer, char **buffer,
|
||||
size_t *maxlen, size_t *retlen, int *truncated,
|
||||
const char *format, va_list args);
|
||||
size_t *maxlen, size_t *retlen, int *truncated,
|
||||
const char *format, va_list args);
|
||||
|
||||
/* format read states */
|
||||
#define DP_S_DEFAULT 0
|
||||
@@ -166,14 +166,10 @@ static void _dopr(char **sbuffer, char **buffer,
|
||||
#define OSSL_MAX(p,q) ((p >= q) ? p : q)
|
||||
|
||||
static void
|
||||
_dopr(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *maxlen,
|
||||
size_t *retlen,
|
||||
int *truncated,
|
||||
const char *format,
|
||||
va_list args)
|
||||
_dopr(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *maxlen,
|
||||
size_t *retlen, int *truncated, const char *format, va_list args)
|
||||
{
|
||||
char ch;
|
||||
LLONG value;
|
||||
@@ -200,7 +196,7 @@ _dopr(
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
doapr_outch(sbuffer,buffer, &currlen, maxlen, ch);
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
@@ -321,15 +317,13 @@ _dopr(
|
||||
value = (unsigned short int)va_arg(args, unsigned int);
|
||||
break;
|
||||
case DP_C_LONG:
|
||||
value = (LLONG) va_arg(args,
|
||||
unsigned long int);
|
||||
value = (LLONG) va_arg(args, unsigned long int);
|
||||
break;
|
||||
case DP_C_LLONG:
|
||||
value = va_arg(args, unsigned LLONG);
|
||||
break;
|
||||
default:
|
||||
value = (LLONG) va_arg(args,
|
||||
unsigned int);
|
||||
value = (LLONG) va_arg(args, unsigned int);
|
||||
break;
|
||||
}
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen, value,
|
||||
@@ -362,25 +356,25 @@ _dopr(
|
||||
break;
|
||||
case 'c':
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen,
|
||||
va_arg(args, int));
|
||||
va_arg(args, int));
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg(args, char *);
|
||||
if (max < 0) {
|
||||
if (buffer)
|
||||
max = INT_MAX;
|
||||
else
|
||||
max = *maxlen;
|
||||
}
|
||||
if (buffer)
|
||||
max = INT_MAX;
|
||||
else
|
||||
max = *maxlen;
|
||||
}
|
||||
fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue,
|
||||
flags, min, max);
|
||||
break;
|
||||
case 'p':
|
||||
value = (long)va_arg(args, void *);
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 16, min, max, flags|DP_F_NUM);
|
||||
value, 16, min, max, flags | DP_F_NUM);
|
||||
break;
|
||||
case 'n': /* XXX */
|
||||
case 'n': /* XXX */
|
||||
if (cflags == DP_C_SHORT) {
|
||||
short int *num;
|
||||
num = va_arg(args, short int *);
|
||||
@@ -388,13 +382,13 @@ _dopr(
|
||||
} else if (cflags == DP_C_LONG) { /* XXX */
|
||||
long int *num;
|
||||
num = va_arg(args, long int *);
|
||||
*num = (long int) currlen;
|
||||
*num = (long int)currlen;
|
||||
} else if (cflags == DP_C_LLONG) { /* XXX */
|
||||
LLONG *num;
|
||||
num = va_arg(args, LLONG *);
|
||||
*num = (LLONG) currlen;
|
||||
} else {
|
||||
int *num;
|
||||
int *num;
|
||||
num = va_arg(args, int *);
|
||||
*num = currlen;
|
||||
}
|
||||
@@ -430,23 +424,17 @@ _dopr(
|
||||
}
|
||||
|
||||
static void
|
||||
fmtstr(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
const char *value,
|
||||
int flags,
|
||||
int min,
|
||||
int max)
|
||||
fmtstr(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen, const char *value, int flags, int min, int max)
|
||||
{
|
||||
int padlen, strln;
|
||||
int cnt = 0;
|
||||
|
||||
if (value == 0)
|
||||
value = "<NULL>";
|
||||
for (strln = 0; value[strln]; ++strln)
|
||||
;
|
||||
for (strln = 0; value[strln]; ++strln) ;
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
@@ -470,21 +458,15 @@ fmtstr(
|
||||
}
|
||||
|
||||
static void
|
||||
fmtint(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
LLONG value,
|
||||
int base,
|
||||
int min,
|
||||
int max,
|
||||
int flags)
|
||||
fmtint(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen, LLONG value, int base, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
const char *prefix = "";
|
||||
unsigned LLONG uvalue;
|
||||
char convert[DECIMAL_SIZE(value)+3];
|
||||
char convert[DECIMAL_SIZE(value) + 3];
|
||||
int place = 0;
|
||||
int spadlen = 0;
|
||||
int zpadlen = 0;
|
||||
@@ -503,23 +485,25 @@ fmtint(
|
||||
signvalue = ' ';
|
||||
}
|
||||
if (flags & DP_F_NUM) {
|
||||
if (base == 8) prefix = "0";
|
||||
if (base == 16) prefix = "0x";
|
||||
if (base == 8)
|
||||
prefix = "0";
|
||||
if (base == 16)
|
||||
prefix = "0x";
|
||||
}
|
||||
if (flags & DP_F_UP)
|
||||
caps = 1;
|
||||
do {
|
||||
convert[place++] =
|
||||
(caps ? "0123456789ABCDEF" : "0123456789abcdef")
|
||||
[uvalue % (unsigned) base];
|
||||
uvalue = (uvalue / (unsigned) base);
|
||||
convert[place++] = (caps ? "0123456789ABCDEF" : "0123456789abcdef")
|
||||
[uvalue % (unsigned)base];
|
||||
uvalue = (uvalue / (unsigned)base);
|
||||
} while (uvalue && (place < (int)sizeof(convert)));
|
||||
if (place == sizeof(convert))
|
||||
place--;
|
||||
convert[place] = 0;
|
||||
|
||||
zpadlen = max - place;
|
||||
spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix);
|
||||
spadlen =
|
||||
min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix);
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (spadlen < 0)
|
||||
@@ -543,8 +527,8 @@ fmtint(
|
||||
|
||||
/* prefix */
|
||||
while (*prefix) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
|
||||
prefix++;
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
|
||||
prefix++;
|
||||
}
|
||||
|
||||
/* zeros */
|
||||
@@ -566,8 +550,7 @@ fmtint(
|
||||
return;
|
||||
}
|
||||
|
||||
static LDOUBLE
|
||||
abs_val(LDOUBLE value)
|
||||
static LDOUBLE abs_val(LDOUBLE value)
|
||||
{
|
||||
LDOUBLE result = value;
|
||||
if (value < 0)
|
||||
@@ -575,8 +558,7 @@ abs_val(LDOUBLE value)
|
||||
return result;
|
||||
}
|
||||
|
||||
static LDOUBLE
|
||||
pow_10(int in_exp)
|
||||
static LDOUBLE pow_10(int in_exp)
|
||||
{
|
||||
LDOUBLE result = 1;
|
||||
while (in_exp) {
|
||||
@@ -586,11 +568,10 @@ pow_10(int in_exp)
|
||||
return result;
|
||||
}
|
||||
|
||||
static long
|
||||
roundv(LDOUBLE value)
|
||||
static long roundv(LDOUBLE value)
|
||||
{
|
||||
long intpart;
|
||||
intpart = (long) value;
|
||||
intpart = (long)value;
|
||||
value = value - intpart;
|
||||
if (value >= 0.5)
|
||||
intpart++;
|
||||
@@ -598,15 +579,10 @@ roundv(LDOUBLE value)
|
||||
}
|
||||
|
||||
static void
|
||||
fmtfp(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
LDOUBLE fvalue,
|
||||
int min,
|
||||
int max,
|
||||
int flags)
|
||||
fmtfp(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen, LDOUBLE fvalue, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
LDOUBLE ufvalue;
|
||||
@@ -616,7 +592,6 @@ fmtfp(
|
||||
int fplace = 0;
|
||||
int padlen = 0;
|
||||
int zpadlen = 0;
|
||||
int caps = 0;
|
||||
long intpart;
|
||||
long fracpart;
|
||||
long max10;
|
||||
@@ -633,13 +608,17 @@ fmtfp(
|
||||
|
||||
intpart = (long)ufvalue;
|
||||
|
||||
/* sorry, we only support 9 digits past the decimal because of our
|
||||
conversion method */
|
||||
/*
|
||||
* sorry, we only support 9 digits past the decimal because of our
|
||||
* conversion method
|
||||
*/
|
||||
if (max > 9)
|
||||
max = 9;
|
||||
|
||||
/* we "cheat" by converting the fractional part to integer by
|
||||
multiplying by a factor of 10 */
|
||||
/*
|
||||
* we "cheat" by converting the fractional part to integer by multiplying
|
||||
* by a factor of 10
|
||||
*/
|
||||
max10 = roundv(pow_10(max));
|
||||
fracpart = roundv(pow_10(max) * (ufvalue - intpart));
|
||||
|
||||
@@ -650,9 +629,7 @@ fmtfp(
|
||||
|
||||
/* convert integer part */
|
||||
do {
|
||||
iconvert[iplace++] =
|
||||
(caps ? "0123456789ABCDEF"
|
||||
: "0123456789abcdef")[intpart % 10];
|
||||
iconvert[iplace++] = "0123456789"[intpart % 10];
|
||||
intpart = (intpart / 10);
|
||||
} while (intpart && (iplace < (int)sizeof(iconvert)));
|
||||
if (iplace == sizeof iconvert)
|
||||
@@ -661,9 +638,7 @@ fmtfp(
|
||||
|
||||
/* convert fractional part */
|
||||
do {
|
||||
fconvert[fplace++] =
|
||||
(caps ? "0123456789ABCDEF"
|
||||
: "0123456789abcdef")[fracpart % 10];
|
||||
fconvert[fplace++] = "0123456789"[fracpart % 10];
|
||||
fracpart = (fracpart / 10);
|
||||
} while (fplace < max);
|
||||
if (fplace == sizeof fconvert)
|
||||
@@ -723,41 +698,42 @@ fmtfp(
|
||||
}
|
||||
|
||||
static void
|
||||
doapr_outch(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
int c)
|
||||
doapr_outch(char **sbuffer,
|
||||
char **buffer, size_t *currlen, size_t *maxlen, int c)
|
||||
{
|
||||
/* If we haven't at least one buffer, someone has doe a big booboo */
|
||||
assert(*sbuffer != NULL || buffer != NULL);
|
||||
|
||||
if (buffer) {
|
||||
while (*currlen >= *maxlen) {
|
||||
if (*buffer == NULL) {
|
||||
if (*maxlen == 0)
|
||||
*maxlen = 1024;
|
||||
*buffer = OPENSSL_malloc(*maxlen);
|
||||
if (*currlen > 0) {
|
||||
assert(*sbuffer != NULL);
|
||||
memcpy(*buffer, *sbuffer, *currlen);
|
||||
}
|
||||
*sbuffer = NULL;
|
||||
} else {
|
||||
*maxlen += 1024;
|
||||
*buffer = OPENSSL_realloc(*buffer, *maxlen);
|
||||
}
|
||||
}
|
||||
/* What to do if *buffer is NULL? */
|
||||
assert(*sbuffer != NULL || *buffer != NULL);
|
||||
/* |currlen| must always be <= |*maxlen| */
|
||||
assert(*currlen <= *maxlen);
|
||||
|
||||
if (buffer && *currlen == *maxlen) {
|
||||
*maxlen += 1024;
|
||||
if (*buffer == NULL) {
|
||||
*buffer = OPENSSL_malloc(*maxlen);
|
||||
if (!*buffer) {
|
||||
/* Panic! Can't really do anything sensible. Just return */
|
||||
return;
|
||||
}
|
||||
if (*currlen > 0) {
|
||||
assert(*sbuffer != NULL);
|
||||
memcpy(*buffer, *sbuffer, *currlen);
|
||||
}
|
||||
*sbuffer = NULL;
|
||||
} else {
|
||||
*buffer = OPENSSL_realloc(*buffer, *maxlen);
|
||||
if (!*buffer) {
|
||||
/* Panic! Can't really do anything sensible. Just return */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*currlen < *maxlen) {
|
||||
if (*sbuffer)
|
||||
(*sbuffer)[(*currlen)++] = (char)c;
|
||||
else
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
if (*sbuffer)
|
||||
(*sbuffer)[(*currlen)++] = (char)c;
|
||||
else
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -765,78 +741,78 @@ doapr_outch(
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int BIO_printf (BIO *bio, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
int BIO_printf(BIO *bio, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
va_start(args, format);
|
||||
|
||||
ret = BIO_vprintf(bio, format, args);
|
||||
ret = BIO_vprintf(bio, format, args);
|
||||
|
||||
va_end(args);
|
||||
return(ret);
|
||||
}
|
||||
va_end(args);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int BIO_vprintf (BIO *bio, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
size_t retlen;
|
||||
char hugebuf[1024*2]; /* Was previously 10k, which is unreasonable
|
||||
in small-stack environments, like threads
|
||||
or DOS programs. */
|
||||
char *hugebufp = hugebuf;
|
||||
size_t hugebufsize = sizeof(hugebuf);
|
||||
char *dynbuf = NULL;
|
||||
int ignored;
|
||||
int BIO_vprintf(BIO *bio, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
size_t retlen;
|
||||
char hugebuf[1024 * 2]; /* Was previously 10k, which is unreasonable
|
||||
* in small-stack environments, like threads
|
||||
* or DOS programs. */
|
||||
char *hugebufp = hugebuf;
|
||||
size_t hugebufsize = sizeof(hugebuf);
|
||||
char *dynbuf = NULL;
|
||||
int ignored;
|
||||
|
||||
dynbuf = NULL;
|
||||
CRYPTO_push_info("doapr()");
|
||||
_dopr(&hugebufp, &dynbuf, &hugebufsize,
|
||||
&retlen, &ignored, format, args);
|
||||
if (dynbuf)
|
||||
{
|
||||
ret=BIO_write(bio, dynbuf, (int)retlen);
|
||||
OPENSSL_free(dynbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret=BIO_write(bio, hugebuf, (int)retlen);
|
||||
}
|
||||
CRYPTO_pop_info();
|
||||
return(ret);
|
||||
}
|
||||
dynbuf = NULL;
|
||||
CRYPTO_push_info("doapr()");
|
||||
_dopr(&hugebufp, &dynbuf, &hugebufsize, &retlen, &ignored, format, args);
|
||||
if (dynbuf) {
|
||||
ret = BIO_write(bio, dynbuf, (int)retlen);
|
||||
OPENSSL_free(dynbuf);
|
||||
} else {
|
||||
ret = BIO_write(bio, hugebuf, (int)retlen);
|
||||
}
|
||||
CRYPTO_pop_info();
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* As snprintf is not available everywhere, we provide our own implementation.
|
||||
* This function has nothing to do with BIOs, but it's closely related
|
||||
* to BIO_printf, and we need *some* name prefix ...
|
||||
* (XXX the function should be renamed, but to what?) */
|
||||
/*
|
||||
* As snprintf is not available everywhere, we provide our own
|
||||
* implementation. This function has nothing to do with BIOs, but it's
|
||||
* closely related to BIO_printf, and we need *some* name prefix ... (XXX the
|
||||
* function should be renamed, but to what?)
|
||||
*/
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
va_start(args, format);
|
||||
|
||||
ret = BIO_vsnprintf(buf, n, format, args);
|
||||
ret = BIO_vsnprintf(buf, n, format, args);
|
||||
|
||||
va_end(args);
|
||||
return(ret);
|
||||
}
|
||||
va_end(args);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||
{
|
||||
size_t retlen;
|
||||
int truncated;
|
||||
{
|
||||
size_t retlen;
|
||||
int truncated;
|
||||
|
||||
_dopr(&buf, NULL, &n, &retlen, &truncated, format, args);
|
||||
_dopr(&buf, NULL, &n, &retlen, &truncated, format, args);
|
||||
|
||||
if (truncated)
|
||||
/* In case of truncation, return -1 like traditional snprintf.
|
||||
* (Current drafts for ISO/IEC 9899 say snprintf should return
|
||||
* the number of characters that would have been written,
|
||||
* had the buffer been large enough.) */
|
||||
return -1;
|
||||
else
|
||||
return (retlen <= INT_MAX) ? (int)retlen : -1;
|
||||
}
|
||||
if (truncated)
|
||||
/*
|
||||
* In case of truncation, return -1 like traditional snprintf.
|
||||
* (Current drafts for ISO/IEC 9899 say snprintf should return the
|
||||
* number of characters that would have been written, had the buffer
|
||||
* been large enough.)
|
||||
*/
|
||||
return -1;
|
||||
else
|
||||
return (retlen <= INT_MAX) ? (int)retlen : -1;
|
||||
}
|
||||
|
||||
Binary file not shown.
1580
crypto/bio/b_sock.c
1580
crypto/bio/b_sock.c
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -61,7 +61,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
static int buffer_write(BIO *h, const char *buf,int num);
|
||||
static int buffer_write(BIO *h, const char *buf, int num);
|
||||
static int buffer_read(BIO *h, char *buf, int size);
|
||||
static int buffer_puts(BIO *h, const char *str);
|
||||
static int buffer_gets(BIO *h, char *str, int size);
|
||||
@@ -69,443 +69,449 @@ static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int buffer_new(BIO *h);
|
||||
static int buffer_free(BIO *data);
|
||||
static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
#define DEFAULT_BUFFER_SIZE 4096
|
||||
#define DEFAULT_BUFFER_SIZE 4096
|
||||
|
||||
static BIO_METHOD methods_buffer=
|
||||
{
|
||||
BIO_TYPE_BUFFER,
|
||||
"buffer",
|
||||
buffer_write,
|
||||
buffer_read,
|
||||
buffer_puts,
|
||||
buffer_gets,
|
||||
buffer_ctrl,
|
||||
buffer_new,
|
||||
buffer_free,
|
||||
buffer_callback_ctrl,
|
||||
};
|
||||
static BIO_METHOD methods_buffer = {
|
||||
BIO_TYPE_BUFFER,
|
||||
"buffer",
|
||||
buffer_write,
|
||||
buffer_read,
|
||||
buffer_puts,
|
||||
buffer_gets,
|
||||
buffer_ctrl,
|
||||
buffer_new,
|
||||
buffer_free,
|
||||
buffer_callback_ctrl,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_buffer(void)
|
||||
{
|
||||
return(&methods_buffer);
|
||||
}
|
||||
{
|
||||
return (&methods_buffer);
|
||||
}
|
||||
|
||||
static int buffer_new(BIO *bi)
|
||||
{
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
{
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
|
||||
ctx=(BIO_F_BUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
|
||||
if (ctx == NULL) return(0);
|
||||
ctx->ibuf=(char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->ibuf == NULL) { OPENSSL_free(ctx); return(0); }
|
||||
ctx->obuf=(char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) { OPENSSL_free(ctx->ibuf); OPENSSL_free(ctx); return(0); }
|
||||
ctx->ibuf_size=DEFAULT_BUFFER_SIZE;
|
||||
ctx->obuf_size=DEFAULT_BUFFER_SIZE;
|
||||
ctx->ibuf_len=0;
|
||||
ctx->ibuf_off=0;
|
||||
ctx->obuf_len=0;
|
||||
ctx->obuf_off=0;
|
||||
ctx = (BIO_F_BUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
|
||||
if (ctx == NULL)
|
||||
return (0);
|
||||
ctx->ibuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->ibuf == NULL) {
|
||||
OPENSSL_free(ctx);
|
||||
return (0);
|
||||
}
|
||||
ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) {
|
||||
OPENSSL_free(ctx->ibuf);
|
||||
OPENSSL_free(ctx);
|
||||
return (0);
|
||||
}
|
||||
ctx->ibuf_size = DEFAULT_BUFFER_SIZE;
|
||||
ctx->obuf_size = DEFAULT_BUFFER_SIZE;
|
||||
ctx->ibuf_len = 0;
|
||||
ctx->ibuf_off = 0;
|
||||
ctx->obuf_len = 0;
|
||||
ctx->obuf_off = 0;
|
||||
|
||||
bi->init=1;
|
||||
bi->ptr=(char *)ctx;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
bi->init = 1;
|
||||
bi->ptr = (char *)ctx;
|
||||
bi->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int buffer_free(BIO *a)
|
||||
{
|
||||
BIO_F_BUFFER_CTX *b;
|
||||
{
|
||||
BIO_F_BUFFER_CTX *b;
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
b = (BIO_F_BUFFER_CTX *)a->ptr;
|
||||
if (b->ibuf != NULL)
|
||||
OPENSSL_free(b->ibuf);
|
||||
if (b->obuf != NULL)
|
||||
OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr = NULL;
|
||||
a->init = 0;
|
||||
a->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (a == NULL) return(0);
|
||||
b=(BIO_F_BUFFER_CTX *)a->ptr;
|
||||
if (b->ibuf != NULL) OPENSSL_free(b->ibuf);
|
||||
if (b->obuf != NULL) OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int buffer_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int i,num=0;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
{
|
||||
int i, num = 0;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
ctx=(BIO_F_BUFFER_CTX *)b->ptr;
|
||||
if (out == NULL)
|
||||
return (0);
|
||||
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
|
||||
|
||||
if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
|
||||
num=0;
|
||||
BIO_clear_retry_flags(b);
|
||||
if ((ctx == NULL) || (b->next_bio == NULL))
|
||||
return (0);
|
||||
num = 0;
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
start:
|
||||
i=ctx->ibuf_len;
|
||||
/* If there is stuff left over, grab it */
|
||||
if (i != 0)
|
||||
{
|
||||
if (i > outl) i=outl;
|
||||
memcpy(out,&(ctx->ibuf[ctx->ibuf_off]),i);
|
||||
ctx->ibuf_off+=i;
|
||||
ctx->ibuf_len-=i;
|
||||
num+=i;
|
||||
if (outl == i) return(num);
|
||||
outl-=i;
|
||||
out+=i;
|
||||
}
|
||||
start:
|
||||
i = ctx->ibuf_len;
|
||||
/* If there is stuff left over, grab it */
|
||||
if (i != 0) {
|
||||
if (i > outl)
|
||||
i = outl;
|
||||
memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i);
|
||||
ctx->ibuf_off += i;
|
||||
ctx->ibuf_len -= i;
|
||||
num += i;
|
||||
if (outl == i)
|
||||
return (num);
|
||||
outl -= i;
|
||||
out += i;
|
||||
}
|
||||
|
||||
/* We may have done a partial read. try to do more.
|
||||
* We have nothing in the buffer.
|
||||
* If we get an error and have read some data, just return it
|
||||
* and let them retry to get the error again.
|
||||
* copy direct to parent address space */
|
||||
if (outl > ctx->ibuf_size)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
i=BIO_read(b->next_bio,out,outl);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
num+=i;
|
||||
if (outl == i) return(num);
|
||||
out+=i;
|
||||
outl-=i;
|
||||
}
|
||||
}
|
||||
/* else */
|
||||
/*
|
||||
* We may have done a partial read. try to do more. We have nothing in
|
||||
* the buffer. If we get an error and have read some data, just return it
|
||||
* and let them retry to get the error again. copy direct to parent
|
||||
* address space
|
||||
*/
|
||||
if (outl > ctx->ibuf_size) {
|
||||
for (;;) {
|
||||
i = BIO_read(b->next_bio, out, outl);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
num += i;
|
||||
if (outl == i)
|
||||
return (num);
|
||||
out += i;
|
||||
outl -= i;
|
||||
}
|
||||
}
|
||||
/* else */
|
||||
|
||||
/* we are going to be doing some buffering */
|
||||
i=BIO_read(b->next_bio,ctx->ibuf,ctx->ibuf_size);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
ctx->ibuf_off=0;
|
||||
ctx->ibuf_len=i;
|
||||
/* we are going to be doing some buffering */
|
||||
i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
ctx->ibuf_off = 0;
|
||||
ctx->ibuf_len = i;
|
||||
|
||||
/* Lets re-read using ourselves :-) */
|
||||
goto start;
|
||||
}
|
||||
/* Lets re-read using ourselves :-) */
|
||||
goto start;
|
||||
}
|
||||
|
||||
static int buffer_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int i,num=0;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
{
|
||||
int i, num = 0;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
|
||||
if ((in == NULL) || (inl <= 0)) return(0);
|
||||
ctx=(BIO_F_BUFFER_CTX *)b->ptr;
|
||||
if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
|
||||
if ((in == NULL) || (inl <= 0))
|
||||
return (0);
|
||||
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
|
||||
if ((ctx == NULL) || (b->next_bio == NULL))
|
||||
return (0);
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
start:
|
||||
i=ctx->obuf_size-(ctx->obuf_len+ctx->obuf_off);
|
||||
/* add to buffer and return */
|
||||
if (i >= inl)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),in,inl);
|
||||
ctx->obuf_len+=inl;
|
||||
return(num+inl);
|
||||
}
|
||||
/* else */
|
||||
/* stuff already in buffer, so add to it first, then flush */
|
||||
if (ctx->obuf_len != 0)
|
||||
{
|
||||
if (i > 0) /* lets fill it up if we can */
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),in,i);
|
||||
in+=i;
|
||||
inl-=i;
|
||||
num+=i;
|
||||
ctx->obuf_len+=i;
|
||||
}
|
||||
/* we now have a full buffer needing flushing */
|
||||
for (;;)
|
||||
{
|
||||
i=BIO_write(b->next_bio,&(ctx->obuf[ctx->obuf_off]),
|
||||
ctx->obuf_len);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
BIO_clear_retry_flags(b);
|
||||
start:
|
||||
i = ctx->obuf_size - (ctx->obuf_len + ctx->obuf_off);
|
||||
/* add to buffer and return */
|
||||
if (i >= inl) {
|
||||
memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, inl);
|
||||
ctx->obuf_len += inl;
|
||||
return (num + inl);
|
||||
}
|
||||
/* else */
|
||||
/* stuff already in buffer, so add to it first, then flush */
|
||||
if (ctx->obuf_len != 0) {
|
||||
if (i > 0) { /* lets fill it up if we can */
|
||||
memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, i);
|
||||
in += i;
|
||||
inl -= i;
|
||||
num += i;
|
||||
ctx->obuf_len += i;
|
||||
}
|
||||
/* we now have a full buffer needing flushing */
|
||||
for (;;) {
|
||||
i = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]),
|
||||
ctx->obuf_len);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
ctx->obuf_off+=i;
|
||||
ctx->obuf_len-=i;
|
||||
if (ctx->obuf_len == 0) break;
|
||||
}
|
||||
}
|
||||
/* we only get here if the buffer has been flushed and we
|
||||
* still have stuff to write */
|
||||
ctx->obuf_off=0;
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
ctx->obuf_off += i;
|
||||
ctx->obuf_len -= i;
|
||||
if (ctx->obuf_len == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* we only get here if the buffer has been flushed and we still have
|
||||
* stuff to write
|
||||
*/
|
||||
ctx->obuf_off = 0;
|
||||
|
||||
/* we now have inl bytes to write */
|
||||
while (inl >= ctx->obuf_size)
|
||||
{
|
||||
i=BIO_write(b->next_bio,in,inl);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
num+=i;
|
||||
in+=i;
|
||||
inl-=i;
|
||||
if (inl == 0) return(num);
|
||||
}
|
||||
/* we now have inl bytes to write */
|
||||
while (inl >= ctx->obuf_size) {
|
||||
i = BIO_write(b->next_bio, in, inl);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
num += i;
|
||||
in += i;
|
||||
inl -= i;
|
||||
if (inl == 0)
|
||||
return (num);
|
||||
}
|
||||
|
||||
/* copy the rest into the buffer since we have only a small
|
||||
* amount left */
|
||||
goto start;
|
||||
}
|
||||
/*
|
||||
* copy the rest into the buffer since we have only a small amount left
|
||||
*/
|
||||
goto start;
|
||||
}
|
||||
|
||||
static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
long ret=1;
|
||||
char *p1,*p2;
|
||||
int r,i,*ip;
|
||||
int ibs,obs;
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
long ret = 1;
|
||||
char *p1, *p2;
|
||||
int r, i, *ip;
|
||||
int ibs, obs;
|
||||
|
||||
ctx=(BIO_F_BUFFER_CTX *)b->ptr;
|
||||
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
ctx->ibuf_off=0;
|
||||
ctx->ibuf_len=0;
|
||||
ctx->obuf_off=0;
|
||||
ctx->obuf_len=0;
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)ctx->obuf_len;
|
||||
break;
|
||||
case BIO_C_GET_BUFF_NUM_LINES:
|
||||
ret=0;
|
||||
p1=ctx->ibuf;
|
||||
for (i=ctx->ibuf_off; i<ctx->ibuf_len; i++)
|
||||
{
|
||||
if (p1[i] == '\n') ret++;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=(long)ctx->obuf_len;
|
||||
if (ret == 0)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
ret=(long)ctx->ibuf_len;
|
||||
if (ret == 0)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUFF_READ_DATA:
|
||||
if (num > ctx->ibuf_size)
|
||||
{
|
||||
p1=OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL) goto malloc_error;
|
||||
if (ctx->ibuf != NULL) OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf=p1;
|
||||
}
|
||||
ctx->ibuf_off=0;
|
||||
ctx->ibuf_len=(int)num;
|
||||
memcpy(ctx->ibuf,ptr,(int)num);
|
||||
ret=1;
|
||||
break;
|
||||
case BIO_C_SET_BUFF_SIZE:
|
||||
if (ptr != NULL)
|
||||
{
|
||||
ip=(int *)ptr;
|
||||
if (*ip == 0)
|
||||
{
|
||||
ibs=(int)num;
|
||||
obs=ctx->obuf_size;
|
||||
}
|
||||
else /* if (*ip == 1) */
|
||||
{
|
||||
ibs=ctx->ibuf_size;
|
||||
obs=(int)num;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ibs=(int)num;
|
||||
obs=(int)num;
|
||||
}
|
||||
p1=ctx->ibuf;
|
||||
p2=ctx->obuf;
|
||||
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size))
|
||||
{
|
||||
p1=(char *)OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL) goto malloc_error;
|
||||
}
|
||||
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size))
|
||||
{
|
||||
p2=(char *)OPENSSL_malloc((int)num);
|
||||
if (p2 == NULL)
|
||||
{
|
||||
if (p1 != ctx->ibuf) OPENSSL_free(p1);
|
||||
goto malloc_error;
|
||||
}
|
||||
}
|
||||
if (ctx->ibuf != p1)
|
||||
{
|
||||
OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf=p1;
|
||||
ctx->ibuf_off=0;
|
||||
ctx->ibuf_len=0;
|
||||
ctx->ibuf_size=ibs;
|
||||
}
|
||||
if (ctx->obuf != p2)
|
||||
{
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf=p2;
|
||||
ctx->obuf_off=0;
|
||||
ctx->obuf_len=0;
|
||||
ctx->obuf_size=obs;
|
||||
}
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
ctx->ibuf_off = 0;
|
||||
ctx->ibuf_len = 0;
|
||||
ctx->obuf_off = 0;
|
||||
ctx->obuf_len = 0;
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret = (long)ctx->obuf_len;
|
||||
break;
|
||||
case BIO_C_GET_BUFF_NUM_LINES:
|
||||
ret = 0;
|
||||
p1 = ctx->ibuf;
|
||||
for (i = 0; i < ctx->ibuf_len; i++) {
|
||||
if (p1[ctx->ibuf_off + i] == '\n')
|
||||
ret++;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret = (long)ctx->obuf_len;
|
||||
if (ret == 0) {
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
ret = (long)ctx->ibuf_len;
|
||||
if (ret == 0) {
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUFF_READ_DATA:
|
||||
if (num > ctx->ibuf_size) {
|
||||
p1 = OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL)
|
||||
goto malloc_error;
|
||||
if (ctx->ibuf != NULL)
|
||||
OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf = p1;
|
||||
}
|
||||
ctx->ibuf_off = 0;
|
||||
ctx->ibuf_len = (int)num;
|
||||
memcpy(ctx->ibuf, ptr, (int)num);
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_C_SET_BUFF_SIZE:
|
||||
if (ptr != NULL) {
|
||||
ip = (int *)ptr;
|
||||
if (*ip == 0) {
|
||||
ibs = (int)num;
|
||||
obs = ctx->obuf_size;
|
||||
} else { /* if (*ip == 1) */
|
||||
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
if (ctx->obuf_len <= 0)
|
||||
{
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
ibs = ctx->ibuf_size;
|
||||
obs = (int)num;
|
||||
}
|
||||
} else {
|
||||
ibs = (int)num;
|
||||
obs = (int)num;
|
||||
}
|
||||
p1 = ctx->ibuf;
|
||||
p2 = ctx->obuf;
|
||||
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) {
|
||||
p1 = (char *)OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) {
|
||||
p2 = (char *)OPENSSL_malloc((int)num);
|
||||
if (p2 == NULL) {
|
||||
if (p1 != ctx->ibuf)
|
||||
OPENSSL_free(p1);
|
||||
goto malloc_error;
|
||||
}
|
||||
}
|
||||
if (ctx->ibuf != p1) {
|
||||
OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf = p1;
|
||||
ctx->ibuf_off = 0;
|
||||
ctx->ibuf_len = 0;
|
||||
ctx->ibuf_size = ibs;
|
||||
}
|
||||
if (ctx->obuf != p2) {
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf = p2;
|
||||
ctx->obuf_off = 0;
|
||||
ctx->obuf_len = 0;
|
||||
ctx->obuf_size = obs;
|
||||
}
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > ctx->obuf_off)
|
||||
{
|
||||
r=BIO_write(b->next_bio,
|
||||
&(ctx->obuf[ctx->obuf_off]),
|
||||
ctx->obuf_len-ctx->obuf_off);
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
if (ctx->obuf_len <= 0) {
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > 0) {
|
||||
r = BIO_write(b->next_bio,
|
||||
&(ctx->obuf[ctx->obuf_off]), ctx->obuf_len);
|
||||
#if 0
|
||||
fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_off,r);
|
||||
fprintf(stderr, "FLUSH [%3d] %3d -> %3d\n", ctx->obuf_off,
|
||||
ctx->obuf_len, r);
|
||||
#endif
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0) return((long)r);
|
||||
ctx->obuf_off+=r;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->obuf_len=0;
|
||||
ctx->obuf_off=0;
|
||||
ret=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio=(BIO *)ptr;
|
||||
if ( !BIO_set_read_buffer_size(dbio,ctx->ibuf_size) ||
|
||||
!BIO_set_write_buffer_size(dbio,ctx->obuf_size))
|
||||
ret=0;
|
||||
break;
|
||||
default:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
malloc_error:
|
||||
BIOerr(BIO_F_BUFFER_CTRL,ERR_R_MALLOC_FAILURE);
|
||||
return(0);
|
||||
}
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0)
|
||||
return ((long)r);
|
||||
ctx->obuf_off += r;
|
||||
ctx->obuf_len -= r;
|
||||
} else {
|
||||
ctx->obuf_len = 0;
|
||||
ctx->obuf_off = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio = (BIO *)ptr;
|
||||
if (!BIO_set_read_buffer_size(dbio, ctx->ibuf_size) ||
|
||||
!BIO_set_write_buffer_size(dbio, ctx->obuf_size))
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
malloc_error:
|
||||
BIOerr(BIO_F_BUFFER_CTRL, ERR_R_MALLOC_FAILURE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static long buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
default:
|
||||
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int buffer_gets(BIO *b, char *buf, int size)
|
||||
{
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
int num=0,i,flag;
|
||||
char *p;
|
||||
{
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
int num = 0, i, flag;
|
||||
char *p;
|
||||
|
||||
ctx=(BIO_F_BUFFER_CTX *)b->ptr;
|
||||
size--; /* reserve space for a '\0' */
|
||||
BIO_clear_retry_flags(b);
|
||||
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
|
||||
size--; /* reserve space for a '\0' */
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (ctx->ibuf_len > 0)
|
||||
{
|
||||
p= &(ctx->ibuf[ctx->ibuf_off]);
|
||||
flag=0;
|
||||
for (i=0; (i<ctx->ibuf_len) && (i<size); i++)
|
||||
{
|
||||
*(buf++)=p[i];
|
||||
if (p[i] == '\n')
|
||||
{
|
||||
flag=1;
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
num+=i;
|
||||
size-=i;
|
||||
ctx->ibuf_len-=i;
|
||||
ctx->ibuf_off+=i;
|
||||
if (flag || size == 0)
|
||||
{
|
||||
*buf='\0';
|
||||
return(num);
|
||||
}
|
||||
}
|
||||
else /* read another chunk */
|
||||
{
|
||||
i=BIO_read(b->next_bio,ctx->ibuf,ctx->ibuf_size);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
*buf='\0';
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
ctx->ibuf_len=i;
|
||||
ctx->ibuf_off=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
if (ctx->ibuf_len > 0) {
|
||||
p = &(ctx->ibuf[ctx->ibuf_off]);
|
||||
flag = 0;
|
||||
for (i = 0; (i < ctx->ibuf_len) && (i < size); i++) {
|
||||
*(buf++) = p[i];
|
||||
if (p[i] == '\n') {
|
||||
flag = 1;
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
num += i;
|
||||
size -= i;
|
||||
ctx->ibuf_len -= i;
|
||||
ctx->ibuf_off += i;
|
||||
if (flag || size == 0) {
|
||||
*buf = '\0';
|
||||
return (num);
|
||||
}
|
||||
} else { /* read another chunk */
|
||||
|
||||
i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
*buf = '\0';
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
ctx->ibuf_len = i;
|
||||
ctx->ibuf_off = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int buffer_puts(BIO *b, const char *str)
|
||||
{
|
||||
return(buffer_write(b,str,strlen(str)));
|
||||
}
|
||||
|
||||
{
|
||||
return (buffer_write(b, str, strlen(str)));
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -62,7 +62,7 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
static int linebuffer_write(BIO *h, const char *buf,int num);
|
||||
static int linebuffer_write(BIO *h, const char *buf, int num);
|
||||
static int linebuffer_read(BIO *h, char *buf, int size);
|
||||
static int linebuffer_puts(BIO *h, const char *str);
|
||||
static int linebuffer_gets(BIO *h, char *str, int size);
|
||||
@@ -72,326 +72,320 @@ static int linebuffer_free(BIO *data);
|
||||
static long linebuffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
|
||||
/* A 10k maximum should be enough for most purposes */
|
||||
#define DEFAULT_LINEBUFFER_SIZE 1024*10
|
||||
#define DEFAULT_LINEBUFFER_SIZE 1024*10
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
static BIO_METHOD methods_linebuffer=
|
||||
{
|
||||
BIO_TYPE_LINEBUFFER,
|
||||
"linebuffer",
|
||||
linebuffer_write,
|
||||
linebuffer_read,
|
||||
linebuffer_puts,
|
||||
linebuffer_gets,
|
||||
linebuffer_ctrl,
|
||||
linebuffer_new,
|
||||
linebuffer_free,
|
||||
linebuffer_callback_ctrl,
|
||||
};
|
||||
static BIO_METHOD methods_linebuffer = {
|
||||
BIO_TYPE_LINEBUFFER,
|
||||
"linebuffer",
|
||||
linebuffer_write,
|
||||
linebuffer_read,
|
||||
linebuffer_puts,
|
||||
linebuffer_gets,
|
||||
linebuffer_ctrl,
|
||||
linebuffer_new,
|
||||
linebuffer_free,
|
||||
linebuffer_callback_ctrl,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_linebuffer(void)
|
||||
{
|
||||
return(&methods_linebuffer);
|
||||
}
|
||||
{
|
||||
return (&methods_linebuffer);
|
||||
}
|
||||
|
||||
typedef struct bio_linebuffer_ctx_struct
|
||||
{
|
||||
char *obuf; /* the output char array */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
int obuf_len; /* how many bytes are in it */
|
||||
} BIO_LINEBUFFER_CTX;
|
||||
typedef struct bio_linebuffer_ctx_struct {
|
||||
char *obuf; /* the output char array */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
int obuf_len; /* how many bytes are in it */
|
||||
} BIO_LINEBUFFER_CTX;
|
||||
|
||||
static int linebuffer_new(BIO *bi)
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
|
||||
ctx=(BIO_LINEBUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
|
||||
if (ctx == NULL) return(0);
|
||||
ctx->obuf=(char *)OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) { OPENSSL_free(ctx); return(0); }
|
||||
ctx->obuf_size=DEFAULT_LINEBUFFER_SIZE;
|
||||
ctx->obuf_len=0;
|
||||
ctx = (BIO_LINEBUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
|
||||
if (ctx == NULL)
|
||||
return (0);
|
||||
ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) {
|
||||
OPENSSL_free(ctx);
|
||||
return (0);
|
||||
}
|
||||
ctx->obuf_size = DEFAULT_LINEBUFFER_SIZE;
|
||||
ctx->obuf_len = 0;
|
||||
|
||||
bi->init=1;
|
||||
bi->ptr=(char *)ctx;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
bi->init = 1;
|
||||
bi->ptr = (char *)ctx;
|
||||
bi->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int linebuffer_free(BIO *a)
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *b;
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *b;
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
b = (BIO_LINEBUFFER_CTX *)a->ptr;
|
||||
if (b->obuf != NULL)
|
||||
OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr = NULL;
|
||||
a->init = 0;
|
||||
a->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (a == NULL) return(0);
|
||||
b=(BIO_LINEBUFFER_CTX *)a->ptr;
|
||||
if (b->obuf != NULL) OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int linebuffer_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_read(b->next_bio,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (out == NULL)
|
||||
return (0);
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_read(b->next_bio, out, outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int linebuffer_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int i,num=0,foundnl;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
{
|
||||
int i, num = 0, foundnl;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
|
||||
if ((in == NULL) || (inl <= 0)) return(0);
|
||||
ctx=(BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
|
||||
if ((in == NULL) || (inl <= 0))
|
||||
return (0);
|
||||
ctx = (BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
if ((ctx == NULL) || (b->next_bio == NULL))
|
||||
return (0);
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
do
|
||||
{
|
||||
const char *p;
|
||||
do {
|
||||
const char *p;
|
||||
|
||||
for(p = in; p < in + inl && *p != '\n'; p++)
|
||||
;
|
||||
if (*p == '\n')
|
||||
{
|
||||
p++;
|
||||
foundnl = 1;
|
||||
}
|
||||
else
|
||||
foundnl = 0;
|
||||
for (p = in; p < in + inl && *p != '\n'; p++) ;
|
||||
if (*p == '\n') {
|
||||
p++;
|
||||
foundnl = 1;
|
||||
} else
|
||||
foundnl = 0;
|
||||
|
||||
/* If a NL was found and we already have text in the save
|
||||
buffer, concatenate them and write */
|
||||
while ((foundnl || p - in > ctx->obuf_size - ctx->obuf_len)
|
||||
&& ctx->obuf_len > 0)
|
||||
{
|
||||
int orig_olen = ctx->obuf_len;
|
||||
|
||||
i = ctx->obuf_size - ctx->obuf_len;
|
||||
if (p - in > 0)
|
||||
{
|
||||
if (i >= p - in)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),
|
||||
in,p - in);
|
||||
ctx->obuf_len += p - in;
|
||||
inl -= p - in;
|
||||
num += p - in;
|
||||
in = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),
|
||||
in,i);
|
||||
ctx->obuf_len += i;
|
||||
inl -= i;
|
||||
in += i;
|
||||
num += i;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If a NL was found and we already have text in the save buffer,
|
||||
* concatenate them and write
|
||||
*/
|
||||
while ((foundnl || p - in > ctx->obuf_size - ctx->obuf_len)
|
||||
&& ctx->obuf_len > 0) {
|
||||
int orig_olen = ctx->obuf_len;
|
||||
|
||||
i = ctx->obuf_size - ctx->obuf_len;
|
||||
if (p - in > 0) {
|
||||
if (i >= p - in) {
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]), in, p - in);
|
||||
ctx->obuf_len += p - in;
|
||||
inl -= p - in;
|
||||
num += p - in;
|
||||
in = p;
|
||||
} else {
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]), in, i);
|
||||
ctx->obuf_len += i;
|
||||
inl -= i;
|
||||
in += i;
|
||||
num += i;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
#endif
|
||||
i = BIO_write(b->next_bio, ctx->obuf, ctx->obuf_len);
|
||||
if (i <= 0) {
|
||||
ctx->obuf_len = orig_olen;
|
||||
BIO_copy_next_retry(b);
|
||||
|
||||
#if 0
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
i=BIO_write(b->next_bio,
|
||||
ctx->obuf, ctx->obuf_len);
|
||||
if (i <= 0)
|
||||
{
|
||||
ctx->obuf_len = orig_olen;
|
||||
BIO_copy_next_retry(b);
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
#if 0
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + i, ctx->obuf_len - i);
|
||||
ctx->obuf_len -= i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that the save buffer is emptied, let's write the input buffer
|
||||
* if a NL was found and there is anything to write.
|
||||
*/
|
||||
if ((foundnl || p - in > ctx->obuf_size) && p - in > 0) {
|
||||
#if 0
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
#endif
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
i = BIO_write(b->next_bio, in, p - in);
|
||||
if (i <= 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
#if 0
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + i,
|
||||
ctx->obuf_len - i);
|
||||
ctx->obuf_len-=i;
|
||||
}
|
||||
|
||||
/* Now that the save buffer is emptied, let's write the input
|
||||
buffer if a NL was found and there is anything to write. */
|
||||
if ((foundnl || p - in > ctx->obuf_size) && p - in > 0)
|
||||
{
|
||||
if (i < 0)
|
||||
return ((num > 0) ? num : i);
|
||||
if (i == 0)
|
||||
return (num);
|
||||
}
|
||||
#if 0
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
i=BIO_write(b->next_bio,in,p - in);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
#if 0
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
#if 0
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
num+=i;
|
||||
in+=i;
|
||||
inl-=i;
|
||||
}
|
||||
}
|
||||
while(foundnl && inl > 0);
|
||||
/* We've written as much as we can. The rest of the input buffer, if
|
||||
any, is text that doesn't and with a NL and therefore needs to be
|
||||
saved for the next trip. */
|
||||
if (inl > 0)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]), in, inl);
|
||||
ctx->obuf_len += inl;
|
||||
num += inl;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
num += i;
|
||||
in += i;
|
||||
inl -= i;
|
||||
}
|
||||
}
|
||||
while (foundnl && inl > 0);
|
||||
/*
|
||||
* We've written as much as we can. The rest of the input buffer, if
|
||||
* any, is text that doesn't and with a NL and therefore needs to be
|
||||
* saved for the next trip.
|
||||
*/
|
||||
if (inl > 0) {
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]), in, inl);
|
||||
ctx->obuf_len += inl;
|
||||
num += inl;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
long ret=1;
|
||||
char *p;
|
||||
int r;
|
||||
int obs;
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
long ret = 1;
|
||||
char *p;
|
||||
int r;
|
||||
int obs;
|
||||
|
||||
ctx=(BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
ctx = (BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
ctx->obuf_len=0;
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)ctx->obuf_len;
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=(long)ctx->obuf_len;
|
||||
if (ret == 0)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUFF_SIZE:
|
||||
obs=(int)num;
|
||||
p=ctx->obuf;
|
||||
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size))
|
||||
{
|
||||
p=(char *)OPENSSL_malloc((int)num);
|
||||
if (p == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
if (ctx->obuf != p)
|
||||
{
|
||||
if (ctx->obuf_len > obs)
|
||||
{
|
||||
ctx->obuf_len = obs;
|
||||
}
|
||||
memcpy(p, ctx->obuf, ctx->obuf_len);
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf=p;
|
||||
ctx->obuf_size=obs;
|
||||
}
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
ctx->obuf_len = 0;
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret = (long)ctx->obuf_len;
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret = (long)ctx->obuf_len;
|
||||
if (ret == 0) {
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUFF_SIZE:
|
||||
obs = (int)num;
|
||||
p = ctx->obuf;
|
||||
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {
|
||||
p = (char *)OPENSSL_malloc((int)num);
|
||||
if (p == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
if (ctx->obuf != p) {
|
||||
if (ctx->obuf_len > obs) {
|
||||
ctx->obuf_len = obs;
|
||||
}
|
||||
memcpy(p, ctx->obuf, ctx->obuf_len);
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf = p;
|
||||
ctx->obuf_size = obs;
|
||||
}
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
if (ctx->obuf_len <= 0)
|
||||
{
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
if (ctx->obuf_len <= 0) {
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > 0)
|
||||
{
|
||||
r=BIO_write(b->next_bio,
|
||||
ctx->obuf, ctx->obuf_len);
|
||||
for (;;) {
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > 0) {
|
||||
r = BIO_write(b->next_bio, ctx->obuf, ctx->obuf_len);
|
||||
#if 0
|
||||
fprintf(stderr,"FLUSH %3d -> %3d\n",ctx->obuf_len,r);
|
||||
fprintf(stderr, "FLUSH %3d -> %3d\n", ctx->obuf_len, r);
|
||||
#endif
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0) return((long)r);
|
||||
if (r < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + r,
|
||||
ctx->obuf_len - r);
|
||||
ctx->obuf_len-=r;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->obuf_len=0;
|
||||
ret=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio=(BIO *)ptr;
|
||||
if ( !BIO_set_write_buffer_size(dbio,ctx->obuf_size))
|
||||
ret=0;
|
||||
break;
|
||||
default:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
malloc_error:
|
||||
BIOerr(BIO_F_LINEBUFFER_CTRL,ERR_R_MALLOC_FAILURE);
|
||||
return(0);
|
||||
}
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0)
|
||||
return ((long)r);
|
||||
if (r < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + r, ctx->obuf_len - r);
|
||||
ctx->obuf_len -= r;
|
||||
} else {
|
||||
ctx->obuf_len = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio = (BIO *)ptr;
|
||||
if (!BIO_set_write_buffer_size(dbio, ctx->obuf_size))
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
malloc_error:
|
||||
BIOerr(BIO_F_LINEBUFFER_CTRL, ERR_R_MALLOC_FAILURE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static long linebuffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
default:
|
||||
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int linebuffer_gets(BIO *b, char *buf, int size)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
return(BIO_gets(b->next_bio,buf,size));
|
||||
}
|
||||
{
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
return (BIO_gets(b->next_bio, buf, size));
|
||||
}
|
||||
|
||||
static int linebuffer_puts(BIO *b, const char *str)
|
||||
{
|
||||
return(linebuffer_write(b,str,strlen(str)));
|
||||
}
|
||||
|
||||
{
|
||||
return (linebuffer_write(b, str, strlen(str)));
|
||||
}
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -62,192 +62,192 @@
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/bio.h>
|
||||
|
||||
/* BIO_put and BIO_get both add to the digest,
|
||||
* BIO_gets returns the digest */
|
||||
/*
|
||||
* BIO_put and BIO_get both add to the digest, BIO_gets returns the digest
|
||||
*/
|
||||
|
||||
static int nbiof_write(BIO *h,const char *buf,int num);
|
||||
static int nbiof_read(BIO *h,char *buf,int size);
|
||||
static int nbiof_puts(BIO *h,const char *str);
|
||||
static int nbiof_gets(BIO *h,char *str,int size);
|
||||
static long nbiof_ctrl(BIO *h,int cmd,long arg1,void *arg2);
|
||||
static int nbiof_write(BIO *h, const char *buf, int num);
|
||||
static int nbiof_read(BIO *h, char *buf, int size);
|
||||
static int nbiof_puts(BIO *h, const char *str);
|
||||
static int nbiof_gets(BIO *h, char *str, int size);
|
||||
static long nbiof_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int nbiof_new(BIO *h);
|
||||
static int nbiof_free(BIO *data);
|
||||
static long nbiof_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
|
||||
typedef struct nbio_test_st
|
||||
{
|
||||
/* only set if we sent a 'should retry' error */
|
||||
int lrn;
|
||||
int lwn;
|
||||
} NBIO_TEST;
|
||||
static long nbiof_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
typedef struct nbio_test_st {
|
||||
/* only set if we sent a 'should retry' error */
|
||||
int lrn;
|
||||
int lwn;
|
||||
} NBIO_TEST;
|
||||
|
||||
static BIO_METHOD methods_nbiof=
|
||||
{
|
||||
BIO_TYPE_NBIO_TEST,
|
||||
"non-blocking IO test filter",
|
||||
nbiof_write,
|
||||
nbiof_read,
|
||||
nbiof_puts,
|
||||
nbiof_gets,
|
||||
nbiof_ctrl,
|
||||
nbiof_new,
|
||||
nbiof_free,
|
||||
nbiof_callback_ctrl,
|
||||
};
|
||||
static BIO_METHOD methods_nbiof = {
|
||||
BIO_TYPE_NBIO_TEST,
|
||||
"non-blocking IO test filter",
|
||||
nbiof_write,
|
||||
nbiof_read,
|
||||
nbiof_puts,
|
||||
nbiof_gets,
|
||||
nbiof_ctrl,
|
||||
nbiof_new,
|
||||
nbiof_free,
|
||||
nbiof_callback_ctrl,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_nbio_test(void)
|
||||
{
|
||||
return(&methods_nbiof);
|
||||
}
|
||||
{
|
||||
return (&methods_nbiof);
|
||||
}
|
||||
|
||||
static int nbiof_new(BIO *bi)
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
|
||||
if (!(nt=(NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST)))) return(0);
|
||||
nt->lrn= -1;
|
||||
nt->lwn= -1;
|
||||
bi->ptr=(char *)nt;
|
||||
bi->init=1;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
if (!(nt = (NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST))))
|
||||
return (0);
|
||||
nt->lrn = -1;
|
||||
nt->lwn = -1;
|
||||
bi->ptr = (char *)nt;
|
||||
bi->init = 1;
|
||||
bi->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int nbiof_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->ptr != NULL)
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->ptr != NULL)
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr = NULL;
|
||||
a->init = 0;
|
||||
a->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int nbiof_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
int ret = 0;
|
||||
#if 1
|
||||
int num;
|
||||
unsigned char n;
|
||||
int num;
|
||||
unsigned char n;
|
||||
#endif
|
||||
|
||||
if (out == NULL) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
if (out == NULL)
|
||||
return (0);
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_clear_retry_flags(b);
|
||||
#if 1
|
||||
RAND_pseudo_bytes(&n,1);
|
||||
num=(n&0x07);
|
||||
if (RAND_pseudo_bytes(&n, 1) < 0)
|
||||
return -1;
|
||||
num = (n & 0x07);
|
||||
|
||||
if (outl > num) outl=num;
|
||||
if (outl > num)
|
||||
outl = num;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
ret= -1;
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
else
|
||||
if (num == 0) {
|
||||
ret = -1;
|
||||
BIO_set_retry_read(b);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ret=BIO_read(b->next_bio,out,outl);
|
||||
if (ret < 0)
|
||||
BIO_copy_next_retry(b);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
ret = BIO_read(b->next_bio, out, outl);
|
||||
if (ret < 0)
|
||||
BIO_copy_next_retry(b);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int nbiof_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
int ret=0;
|
||||
int num;
|
||||
unsigned char n;
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
int ret = 0;
|
||||
int num;
|
||||
unsigned char n;
|
||||
|
||||
if ((in == NULL) || (inl <= 0)) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
nt=(NBIO_TEST *)b->ptr;
|
||||
if ((in == NULL) || (inl <= 0))
|
||||
return (0);
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
nt = (NBIO_TEST *)b->ptr;
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
#if 1
|
||||
if (nt->lwn > 0)
|
||||
{
|
||||
num=nt->lwn;
|
||||
nt->lwn=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RAND_pseudo_bytes(&n,1);
|
||||
num=(n&7);
|
||||
}
|
||||
if (nt->lwn > 0) {
|
||||
num = nt->lwn;
|
||||
nt->lwn = 0;
|
||||
} else {
|
||||
if (RAND_pseudo_bytes(&n, 1) < 0)
|
||||
return -1;
|
||||
num = (n & 7);
|
||||
}
|
||||
|
||||
if (inl > num) inl=num;
|
||||
if (inl > num)
|
||||
inl = num;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
ret= -1;
|
||||
BIO_set_retry_write(b);
|
||||
}
|
||||
else
|
||||
if (num == 0) {
|
||||
ret = -1;
|
||||
BIO_set_retry_write(b);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ret=BIO_write(b->next_bio,in,inl);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
nt->lwn=inl;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
ret = BIO_write(b->next_bio, in, inl);
|
||||
if (ret < 0) {
|
||||
BIO_copy_next_retry(b);
|
||||
nt->lwn = inl;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret;
|
||||
{
|
||||
long ret;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret=0L;
|
||||
break;
|
||||
default:
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret = 0L;
|
||||
break;
|
||||
default:
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long nbiof_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
default:
|
||||
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int nbiof_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_gets(bp->next_bio,buf,size));
|
||||
}
|
||||
|
||||
{
|
||||
if (bp->next_bio == NULL)
|
||||
return (0);
|
||||
return (BIO_gets(bp->next_bio, buf, size));
|
||||
}
|
||||
|
||||
static int nbiof_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_puts(bp->next_bio,str));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
if (bp->next_bio == NULL)
|
||||
return (0);
|
||||
return (BIO_puts(bp->next_bio, str));
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -61,8 +61,9 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
/* BIO_put and BIO_get both add to the digest,
|
||||
* BIO_gets returns the digest */
|
||||
/*
|
||||
* BIO_put and BIO_get both add to the digest, BIO_gets returns the digest
|
||||
*/
|
||||
|
||||
static int nullf_write(BIO *h, const char *buf, int num);
|
||||
static int nullf_read(BIO *h, char *buf, int size);
|
||||
@@ -72,112 +73,117 @@ static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int nullf_new(BIO *h);
|
||||
static int nullf_free(BIO *data);
|
||||
static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
static BIO_METHOD methods_nullf=
|
||||
{
|
||||
BIO_TYPE_NULL_FILTER,
|
||||
"NULL filter",
|
||||
nullf_write,
|
||||
nullf_read,
|
||||
nullf_puts,
|
||||
nullf_gets,
|
||||
nullf_ctrl,
|
||||
nullf_new,
|
||||
nullf_free,
|
||||
nullf_callback_ctrl,
|
||||
};
|
||||
static BIO_METHOD methods_nullf = {
|
||||
BIO_TYPE_NULL_FILTER,
|
||||
"NULL filter",
|
||||
nullf_write,
|
||||
nullf_read,
|
||||
nullf_puts,
|
||||
nullf_gets,
|
||||
nullf_ctrl,
|
||||
nullf_new,
|
||||
nullf_free,
|
||||
nullf_callback_ctrl,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_null(void)
|
||||
{
|
||||
return(&methods_nullf);
|
||||
}
|
||||
{
|
||||
return (&methods_nullf);
|
||||
}
|
||||
|
||||
static int nullf_new(BIO *bi)
|
||||
{
|
||||
bi->init=1;
|
||||
bi->ptr=NULL;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 1;
|
||||
bi->ptr = NULL;
|
||||
bi->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int nullf_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
/* a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;*/
|
||||
return(1);
|
||||
}
|
||||
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
/*-
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
*/
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int nullf_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_read(b->next_bio,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (out == NULL)
|
||||
return (0);
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_read(b->next_bio, out, outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int nullf_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((in == NULL) || (inl <= 0)) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_write(b->next_bio,in,inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
if ((in == NULL) || (inl <= 0))
|
||||
return (0);
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
ret = BIO_write(b->next_bio, in, inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret;
|
||||
{
|
||||
long ret;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch(cmd)
|
||||
{
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret=0L;
|
||||
break;
|
||||
default:
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret = 0L;
|
||||
break;
|
||||
default:
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->next_bio == NULL)
|
||||
return (0);
|
||||
switch (cmd) {
|
||||
default:
|
||||
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int nullf_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_gets(bp->next_bio,buf,size));
|
||||
}
|
||||
|
||||
{
|
||||
if (bp->next_bio == NULL)
|
||||
return (0);
|
||||
return (BIO_gets(bp->next_bio, buf, size));
|
||||
}
|
||||
|
||||
static int nullf_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_puts(bp->next_bio,str));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
if (bp->next_bio == NULL)
|
||||
return (0);
|
||||
return (BIO_puts(bp->next_bio, str));
|
||||
}
|
||||
|
||||
Binary file not shown.
1111
crypto/bio/bio.h
1111
crypto/bio/bio.h
File diff suppressed because it is too large
Load Diff
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -64,80 +64,82 @@
|
||||
#include <openssl/err.h>
|
||||
|
||||
long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
|
||||
int argi, long argl, long ret)
|
||||
{
|
||||
BIO *b;
|
||||
MS_STATIC char buf[256];
|
||||
char *p;
|
||||
long r=1;
|
||||
size_t p_maxlen;
|
||||
int argi, long argl, long ret)
|
||||
{
|
||||
BIO *b;
|
||||
MS_STATIC char buf[256];
|
||||
char *p;
|
||||
long r = 1;
|
||||
int len;
|
||||
size_t p_maxlen;
|
||||
|
||||
if (BIO_CB_RETURN & cmd)
|
||||
r=ret;
|
||||
if (BIO_CB_RETURN & cmd)
|
||||
r = ret;
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"BIO[%08lX]:",(unsigned long)bio);
|
||||
p= &(buf[14]);
|
||||
p_maxlen = sizeof buf - 14;
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CB_FREE:
|
||||
BIO_snprintf(p,p_maxlen,"Free - %s\n",bio->method->name);
|
||||
break;
|
||||
case BIO_CB_READ:
|
||||
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
|
||||
BIO_snprintf(p,p_maxlen,"read(%d,%lu) - %s fd=%d\n",
|
||||
bio->num,(unsigned long)argi,
|
||||
bio->method->name,bio->num);
|
||||
else
|
||||
BIO_snprintf(p,p_maxlen,"read(%d,%lu) - %s\n",
|
||||
bio->num,(unsigned long)argi,
|
||||
bio->method->name);
|
||||
break;
|
||||
case BIO_CB_WRITE:
|
||||
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
|
||||
BIO_snprintf(p,p_maxlen,"write(%d,%lu) - %s fd=%d\n",
|
||||
bio->num,(unsigned long)argi,
|
||||
bio->method->name,bio->num);
|
||||
else
|
||||
BIO_snprintf(p,p_maxlen,"write(%d,%lu) - %s\n",
|
||||
bio->num,(unsigned long)argi,
|
||||
bio->method->name);
|
||||
break;
|
||||
case BIO_CB_PUTS:
|
||||
BIO_snprintf(p,p_maxlen,"puts() - %s\n",bio->method->name);
|
||||
break;
|
||||
case BIO_CB_GETS:
|
||||
BIO_snprintf(p,p_maxlen,"gets(%lu) - %s\n",(unsigned long)argi,bio->method->name);
|
||||
break;
|
||||
case BIO_CB_CTRL:
|
||||
BIO_snprintf(p,p_maxlen,"ctrl(%lu) - %s\n",(unsigned long)argi,bio->method->name);
|
||||
break;
|
||||
case BIO_CB_RETURN|BIO_CB_READ:
|
||||
BIO_snprintf(p,p_maxlen,"read return %ld\n",ret);
|
||||
break;
|
||||
case BIO_CB_RETURN|BIO_CB_WRITE:
|
||||
BIO_snprintf(p,p_maxlen,"write return %ld\n",ret);
|
||||
break;
|
||||
case BIO_CB_RETURN|BIO_CB_GETS:
|
||||
BIO_snprintf(p,p_maxlen,"gets return %ld\n",ret);
|
||||
break;
|
||||
case BIO_CB_RETURN|BIO_CB_PUTS:
|
||||
BIO_snprintf(p,p_maxlen,"puts return %ld\n",ret);
|
||||
break;
|
||||
case BIO_CB_RETURN|BIO_CB_CTRL:
|
||||
BIO_snprintf(p,p_maxlen,"ctrl return %ld\n",ret);
|
||||
break;
|
||||
default:
|
||||
BIO_snprintf(p,p_maxlen,"bio callback - unknown type (%d)\n",cmd);
|
||||
break;
|
||||
}
|
||||
len = BIO_snprintf(buf,sizeof buf,"BIO[%p]: ",(void *)bio);
|
||||
|
||||
b=(BIO *)bio->cb_arg;
|
||||
if (b != NULL)
|
||||
BIO_write(b,buf,strlen(buf));
|
||||
p = buf + len;
|
||||
p_maxlen = sizeof(buf) - len;
|
||||
|
||||
switch (cmd) {
|
||||
case BIO_CB_FREE:
|
||||
BIO_snprintf(p, p_maxlen, "Free - %s\n", bio->method->name);
|
||||
break;
|
||||
case BIO_CB_READ:
|
||||
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
|
||||
BIO_snprintf(p, p_maxlen, "read(%d,%lu) - %s fd=%d\n",
|
||||
bio->num, (unsigned long)argi,
|
||||
bio->method->name, bio->num);
|
||||
else
|
||||
BIO_snprintf(p, p_maxlen, "read(%d,%lu) - %s\n",
|
||||
bio->num, (unsigned long)argi, bio->method->name);
|
||||
break;
|
||||
case BIO_CB_WRITE:
|
||||
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
|
||||
BIO_snprintf(p, p_maxlen, "write(%d,%lu) - %s fd=%d\n",
|
||||
bio->num, (unsigned long)argi,
|
||||
bio->method->name, bio->num);
|
||||
else
|
||||
BIO_snprintf(p, p_maxlen, "write(%d,%lu) - %s\n",
|
||||
bio->num, (unsigned long)argi, bio->method->name);
|
||||
break;
|
||||
case BIO_CB_PUTS:
|
||||
BIO_snprintf(p, p_maxlen, "puts() - %s\n", bio->method->name);
|
||||
break;
|
||||
case BIO_CB_GETS:
|
||||
BIO_snprintf(p, p_maxlen, "gets(%lu) - %s\n", (unsigned long)argi,
|
||||
bio->method->name);
|
||||
break;
|
||||
case BIO_CB_CTRL:
|
||||
BIO_snprintf(p, p_maxlen, "ctrl(%lu) - %s\n", (unsigned long)argi,
|
||||
bio->method->name);
|
||||
break;
|
||||
case BIO_CB_RETURN | BIO_CB_READ:
|
||||
BIO_snprintf(p, p_maxlen, "read return %ld\n", ret);
|
||||
break;
|
||||
case BIO_CB_RETURN | BIO_CB_WRITE:
|
||||
BIO_snprintf(p, p_maxlen, "write return %ld\n", ret);
|
||||
break;
|
||||
case BIO_CB_RETURN | BIO_CB_GETS:
|
||||
BIO_snprintf(p, p_maxlen, "gets return %ld\n", ret);
|
||||
break;
|
||||
case BIO_CB_RETURN | BIO_CB_PUTS:
|
||||
BIO_snprintf(p, p_maxlen, "puts return %ld\n", ret);
|
||||
break;
|
||||
case BIO_CB_RETURN | BIO_CB_CTRL:
|
||||
BIO_snprintf(p, p_maxlen, "ctrl return %ld\n", ret);
|
||||
break;
|
||||
default:
|
||||
BIO_snprintf(p, p_maxlen, "bio callback - unknown type (%d)\n", cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
b = (BIO *)bio->cb_arg;
|
||||
if (b != NULL)
|
||||
BIO_write(b, buf, strlen(buf));
|
||||
#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
|
||||
else
|
||||
fputs(buf,stderr);
|
||||
else
|
||||
fputs(buf, stderr);
|
||||
#endif
|
||||
return(r);
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,13 +1,13 @@
|
||||
/* crypto/bio/bio_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
@@ -53,7 +53,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
/*
|
||||
* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
* made to it will be overwritten when the script next updates this file,
|
||||
* only reason strings will be preserved.
|
||||
*/
|
||||
@@ -65,90 +66,92 @@
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
#define ERR_FUNC(func) ERR_PACK(ERR_LIB_BIO,func,0)
|
||||
#define ERR_REASON(reason) ERR_PACK(ERR_LIB_BIO,0,reason)
|
||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_BIO,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_BIO,0,reason)
|
||||
|
||||
static ERR_STRING_DATA BIO_str_functs[]=
|
||||
{
|
||||
{ERR_FUNC(BIO_F_ACPT_STATE), "ACPT_STATE"},
|
||||
{ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"},
|
||||
{ERR_FUNC(BIO_F_BIO_BER_GET_HEADER), "BIO_BER_GET_HEADER"},
|
||||
{ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"},
|
||||
{ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"},
|
||||
{ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"},
|
||||
{ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_ACCEPT_SOCKET), "BIO_get_accept_socket"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_HOST_IP), "BIO_get_host_ip"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_PORT), "BIO_get_port"},
|
||||
{ERR_FUNC(BIO_F_BIO_MAKE_PAIR), "BIO_MAKE_PAIR"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW), "BIO_new"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW_FILE), "BIO_new_file"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW_MEM_BUF), "BIO_new_mem_buf"},
|
||||
{ERR_FUNC(BIO_F_BIO_NREAD), "BIO_nread"},
|
||||
{ERR_FUNC(BIO_F_BIO_NREAD0), "BIO_nread0"},
|
||||
{ERR_FUNC(BIO_F_BIO_NWRITE), "BIO_nwrite"},
|
||||
{ERR_FUNC(BIO_F_BIO_NWRITE0), "BIO_nwrite0"},
|
||||
{ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"},
|
||||
{ERR_FUNC(BIO_F_BIO_READ), "BIO_read"},
|
||||
{ERR_FUNC(BIO_F_BIO_SOCK_INIT), "BIO_sock_init"},
|
||||
{ERR_FUNC(BIO_F_BIO_WRITE), "BIO_write"},
|
||||
{ERR_FUNC(BIO_F_BUFFER_CTRL), "BUFFER_CTRL"},
|
||||
{ERR_FUNC(BIO_F_CONN_CTRL), "CONN_CTRL"},
|
||||
{ERR_FUNC(BIO_F_CONN_STATE), "CONN_STATE"},
|
||||
{ERR_FUNC(BIO_F_FILE_CTRL), "FILE_CTRL"},
|
||||
{ERR_FUNC(BIO_F_FILE_READ), "FILE_READ"},
|
||||
{ERR_FUNC(BIO_F_LINEBUFFER_CTRL), "LINEBUFFER_CTRL"},
|
||||
{ERR_FUNC(BIO_F_MEM_READ), "MEM_READ"},
|
||||
{ERR_FUNC(BIO_F_MEM_WRITE), "MEM_WRITE"},
|
||||
{ERR_FUNC(BIO_F_SSL_NEW), "SSL_new"},
|
||||
{ERR_FUNC(BIO_F_WSASTARTUP), "WSASTARTUP"},
|
||||
{0,NULL}
|
||||
};
|
||||
static ERR_STRING_DATA BIO_str_functs[] = {
|
||||
{ERR_FUNC(BIO_F_ACPT_STATE), "ACPT_STATE"},
|
||||
{ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"},
|
||||
{ERR_FUNC(BIO_F_BIO_BER_GET_HEADER), "BIO_BER_GET_HEADER"},
|
||||
{ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"},
|
||||
{ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"},
|
||||
{ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"},
|
||||
{ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_ACCEPT_SOCKET), "BIO_get_accept_socket"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_HOST_IP), "BIO_get_host_ip"},
|
||||
{ERR_FUNC(BIO_F_BIO_GET_PORT), "BIO_get_port"},
|
||||
{ERR_FUNC(BIO_F_BIO_MAKE_PAIR), "BIO_MAKE_PAIR"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW), "BIO_new"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW_FILE), "BIO_new_file"},
|
||||
{ERR_FUNC(BIO_F_BIO_NEW_MEM_BUF), "BIO_new_mem_buf"},
|
||||
{ERR_FUNC(BIO_F_BIO_NREAD), "BIO_nread"},
|
||||
{ERR_FUNC(BIO_F_BIO_NREAD0), "BIO_nread0"},
|
||||
{ERR_FUNC(BIO_F_BIO_NWRITE), "BIO_nwrite"},
|
||||
{ERR_FUNC(BIO_F_BIO_NWRITE0), "BIO_nwrite0"},
|
||||
{ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"},
|
||||
{ERR_FUNC(BIO_F_BIO_READ), "BIO_read"},
|
||||
{ERR_FUNC(BIO_F_BIO_SOCK_INIT), "BIO_sock_init"},
|
||||
{ERR_FUNC(BIO_F_BIO_WRITE), "BIO_write"},
|
||||
{ERR_FUNC(BIO_F_BUFFER_CTRL), "BUFFER_CTRL"},
|
||||
{ERR_FUNC(BIO_F_CONN_CTRL), "CONN_CTRL"},
|
||||
{ERR_FUNC(BIO_F_CONN_STATE), "CONN_STATE"},
|
||||
{ERR_FUNC(BIO_F_DGRAM_SCTP_READ), "DGRAM_SCTP_READ"},
|
||||
{ERR_FUNC(BIO_F_DGRAM_SCTP_WRITE), "DGRAM_SCTP_WRITE"},
|
||||
{ERR_FUNC(BIO_F_FILE_CTRL), "FILE_CTRL"},
|
||||
{ERR_FUNC(BIO_F_FILE_READ), "FILE_READ"},
|
||||
{ERR_FUNC(BIO_F_LINEBUFFER_CTRL), "LINEBUFFER_CTRL"},
|
||||
{ERR_FUNC(BIO_F_MEM_READ), "MEM_READ"},
|
||||
{ERR_FUNC(BIO_F_MEM_WRITE), "MEM_WRITE"},
|
||||
{ERR_FUNC(BIO_F_SSL_NEW), "SSL_new"},
|
||||
{ERR_FUNC(BIO_F_WSASTARTUP), "WSASTARTUP"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA BIO_str_reasons[]=
|
||||
{
|
||||
{ERR_REASON(BIO_R_ACCEPT_ERROR) ,"accept error"},
|
||||
{ERR_REASON(BIO_R_BAD_FOPEN_MODE) ,"bad fopen mode"},
|
||||
{ERR_REASON(BIO_R_BAD_HOSTNAME_LOOKUP) ,"bad hostname lookup"},
|
||||
{ERR_REASON(BIO_R_BROKEN_PIPE) ,"broken pipe"},
|
||||
{ERR_REASON(BIO_R_CONNECT_ERROR) ,"connect error"},
|
||||
{ERR_REASON(BIO_R_EOF_ON_MEMORY_BIO) ,"EOF on memory BIO"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO) ,"error setting nbio"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET),"error setting nbio on accepted socket"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET),"error setting nbio on accept socket"},
|
||||
{ERR_REASON(BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET),"gethostbyname addr is not af inet"},
|
||||
{ERR_REASON(BIO_R_INVALID_ARGUMENT) ,"invalid argument"},
|
||||
{ERR_REASON(BIO_R_INVALID_IP_ADDRESS) ,"invalid ip address"},
|
||||
{ERR_REASON(BIO_R_IN_USE) ,"in use"},
|
||||
{ERR_REASON(BIO_R_KEEPALIVE) ,"keepalive"},
|
||||
{ERR_REASON(BIO_R_NBIO_CONNECT_ERROR) ,"nbio connect error"},
|
||||
{ERR_REASON(BIO_R_NO_ACCEPT_PORT_SPECIFIED),"no accept port specified"},
|
||||
{ERR_REASON(BIO_R_NO_HOSTNAME_SPECIFIED) ,"no hostname specified"},
|
||||
{ERR_REASON(BIO_R_NO_PORT_DEFINED) ,"no port defined"},
|
||||
{ERR_REASON(BIO_R_NO_PORT_SPECIFIED) ,"no port specified"},
|
||||
{ERR_REASON(BIO_R_NO_SUCH_FILE) ,"no such file"},
|
||||
{ERR_REASON(BIO_R_NULL_PARAMETER) ,"null parameter"},
|
||||
{ERR_REASON(BIO_R_TAG_MISMATCH) ,"tag mismatch"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_BIND_SOCKET) ,"unable to bind socket"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_CREATE_SOCKET),"unable to create socket"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_LISTEN_SOCKET),"unable to listen socket"},
|
||||
{ERR_REASON(BIO_R_UNINITIALIZED) ,"uninitialized"},
|
||||
{ERR_REASON(BIO_R_UNSUPPORTED_METHOD) ,"unsupported method"},
|
||||
{ERR_REASON(BIO_R_WRITE_TO_READ_ONLY_BIO),"write to read only BIO"},
|
||||
{ERR_REASON(BIO_R_WSASTARTUP) ,"WSAStartup"},
|
||||
{0,NULL}
|
||||
};
|
||||
static ERR_STRING_DATA BIO_str_reasons[] = {
|
||||
{ERR_REASON(BIO_R_ACCEPT_ERROR), "accept error"},
|
||||
{ERR_REASON(BIO_R_BAD_FOPEN_MODE), "bad fopen mode"},
|
||||
{ERR_REASON(BIO_R_BAD_HOSTNAME_LOOKUP), "bad hostname lookup"},
|
||||
{ERR_REASON(BIO_R_BROKEN_PIPE), "broken pipe"},
|
||||
{ERR_REASON(BIO_R_CONNECT_ERROR), "connect error"},
|
||||
{ERR_REASON(BIO_R_EOF_ON_MEMORY_BIO), "EOF on memory BIO"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO), "error setting nbio"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET),
|
||||
"error setting nbio on accepted socket"},
|
||||
{ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET),
|
||||
"error setting nbio on accept socket"},
|
||||
{ERR_REASON(BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET),
|
||||
"gethostbyname addr is not af inet"},
|
||||
{ERR_REASON(BIO_R_INVALID_ARGUMENT), "invalid argument"},
|
||||
{ERR_REASON(BIO_R_INVALID_IP_ADDRESS), "invalid ip address"},
|
||||
{ERR_REASON(BIO_R_IN_USE), "in use"},
|
||||
{ERR_REASON(BIO_R_KEEPALIVE), "keepalive"},
|
||||
{ERR_REASON(BIO_R_NBIO_CONNECT_ERROR), "nbio connect error"},
|
||||
{ERR_REASON(BIO_R_NO_ACCEPT_PORT_SPECIFIED), "no accept port specified"},
|
||||
{ERR_REASON(BIO_R_NO_HOSTNAME_SPECIFIED), "no hostname specified"},
|
||||
{ERR_REASON(BIO_R_NO_PORT_DEFINED), "no port defined"},
|
||||
{ERR_REASON(BIO_R_NO_PORT_SPECIFIED), "no port specified"},
|
||||
{ERR_REASON(BIO_R_NO_SUCH_FILE), "no such file"},
|
||||
{ERR_REASON(BIO_R_NULL_PARAMETER), "null parameter"},
|
||||
{ERR_REASON(BIO_R_TAG_MISMATCH), "tag mismatch"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_BIND_SOCKET), "unable to bind socket"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_CREATE_SOCKET), "unable to create socket"},
|
||||
{ERR_REASON(BIO_R_UNABLE_TO_LISTEN_SOCKET), "unable to listen socket"},
|
||||
{ERR_REASON(BIO_R_UNINITIALIZED), "uninitialized"},
|
||||
{ERR_REASON(BIO_R_UNSUPPORTED_METHOD), "unsupported method"},
|
||||
{ERR_REASON(BIO_R_WRITE_TO_READ_ONLY_BIO), "write to read only BIO"},
|
||||
{ERR_REASON(BIO_R_WSASTARTUP), "WSAStartup"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void ERR_load_BIO_strings(void)
|
||||
{
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,BIO_str_functs);
|
||||
ERR_load_strings(0,BIO_str_reasons);
|
||||
}
|
||||
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings(0, BIO_str_functs);
|
||||
ERR_load_strings(0, BIO_str_reasons);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -2,35 +2,35 @@
|
||||
|
||||
#if BIO_FLAGS_UPLINK==0
|
||||
/* Shortcut UPLINK calls on most platforms... */
|
||||
#define UP_stdin stdin
|
||||
#define UP_stdout stdout
|
||||
#define UP_stderr stderr
|
||||
#define UP_fprintf fprintf
|
||||
#define UP_fgets fgets
|
||||
#define UP_fread fread
|
||||
#define UP_fwrite fwrite
|
||||
#undef UP_fsetmod
|
||||
#define UP_feof feof
|
||||
#define UP_fclose fclose
|
||||
# define UP_stdin stdin
|
||||
# define UP_stdout stdout
|
||||
# define UP_stderr stderr
|
||||
# define UP_fprintf fprintf
|
||||
# define UP_fgets fgets
|
||||
# define UP_fread fread
|
||||
# define UP_fwrite fwrite
|
||||
# undef UP_fsetmod
|
||||
# define UP_feof feof
|
||||
# define UP_fclose fclose
|
||||
|
||||
#define UP_fopen fopen
|
||||
#define UP_fseek fseek
|
||||
#define UP_ftell ftell
|
||||
#define UP_fflush fflush
|
||||
#define UP_ferror ferror
|
||||
#ifdef _WIN32
|
||||
#define UP_fileno _fileno
|
||||
#define UP_open _open
|
||||
#define UP_read _read
|
||||
#define UP_write _write
|
||||
#define UP_lseek _lseek
|
||||
#define UP_close _close
|
||||
#else
|
||||
#define UP_fileno fileno
|
||||
#define UP_open open
|
||||
#define UP_read read
|
||||
#define UP_write write
|
||||
#define UP_lseek lseek
|
||||
#define UP_close close
|
||||
#endif
|
||||
# define UP_fopen fopen
|
||||
# define UP_fseek fseek
|
||||
# define UP_ftell ftell
|
||||
# define UP_fflush fflush
|
||||
# define UP_ferror ferror
|
||||
# ifdef _WIN32
|
||||
# define UP_fileno _fileno
|
||||
# define UP_open _open
|
||||
# define UP_read _read
|
||||
# define UP_write _write
|
||||
# define UP_lseek _lseek
|
||||
# define UP_close _close
|
||||
# else
|
||||
# define UP_fileno fileno
|
||||
# define UP_open open
|
||||
# define UP_read read
|
||||
# define UP_write write
|
||||
# define UP_lseek lseek
|
||||
# define UP_close close
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -64,539 +64,533 @@
|
||||
#include <openssl/stack.h>
|
||||
|
||||
BIO *BIO_new(BIO_METHOD *method)
|
||||
{
|
||||
BIO *ret=NULL;
|
||||
{
|
||||
BIO *ret = NULL;
|
||||
|
||||
ret=(BIO *)OPENSSL_malloc(sizeof(BIO));
|
||||
if (ret == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE);
|
||||
return(NULL);
|
||||
}
|
||||
if (!BIO_set(ret,method))
|
||||
{
|
||||
OPENSSL_free(ret);
|
||||
ret=NULL;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
ret = (BIO *)OPENSSL_malloc(sizeof(BIO));
|
||||
if (ret == NULL) {
|
||||
BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
}
|
||||
if (!BIO_set(ret, method)) {
|
||||
OPENSSL_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int BIO_set(BIO *bio, BIO_METHOD *method)
|
||||
{
|
||||
bio->method=method;
|
||||
bio->callback=NULL;
|
||||
bio->cb_arg=NULL;
|
||||
bio->init=0;
|
||||
bio->shutdown=1;
|
||||
bio->flags=0;
|
||||
bio->retry_reason=0;
|
||||
bio->num=0;
|
||||
bio->ptr=NULL;
|
||||
bio->prev_bio=NULL;
|
||||
bio->next_bio=NULL;
|
||||
bio->references=1;
|
||||
bio->num_read=0L;
|
||||
bio->num_write=0L;
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
|
||||
if (method->create != NULL)
|
||||
if (!method->create(bio))
|
||||
{
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio,
|
||||
&bio->ex_data);
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bio->method = method;
|
||||
bio->callback = NULL;
|
||||
bio->cb_arg = NULL;
|
||||
bio->init = 0;
|
||||
bio->shutdown = 1;
|
||||
bio->flags = 0;
|
||||
bio->retry_reason = 0;
|
||||
bio->num = 0;
|
||||
bio->ptr = NULL;
|
||||
bio->prev_bio = NULL;
|
||||
bio->next_bio = NULL;
|
||||
bio->references = 1;
|
||||
bio->num_read = 0L;
|
||||
bio->num_write = 0L;
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
|
||||
if (method->create != NULL)
|
||||
if (!method->create(bio)) {
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int BIO_free(BIO *a)
|
||||
{
|
||||
int i;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (a == NULL) return(0);
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
|
||||
i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_BIO);
|
||||
i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);
|
||||
#ifdef REF_PRINT
|
||||
REF_PRINT("BIO",a);
|
||||
REF_PRINT("BIO", a);
|
||||
#endif
|
||||
if (i > 0) return(1);
|
||||
if (i > 0)
|
||||
return (1);
|
||||
#ifdef REF_CHECK
|
||||
if (i < 0)
|
||||
{
|
||||
fprintf(stderr,"BIO_free, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
if (i < 0) {
|
||||
fprintf(stderr, "BIO_free, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
if ((a->callback != NULL) &&
|
||||
((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0))
|
||||
return(i);
|
||||
if ((a->callback != NULL) &&
|
||||
((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
|
||||
return (i);
|
||||
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
|
||||
|
||||
if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
|
||||
a->method->destroy(a);
|
||||
OPENSSL_free(a);
|
||||
return(1);
|
||||
}
|
||||
if ((a->method != NULL) && (a->method->destroy != NULL))
|
||||
a->method->destroy(a);
|
||||
OPENSSL_free(a);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void BIO_vfree(BIO *a)
|
||||
{ BIO_free(a); }
|
||||
{
|
||||
BIO_free(a);
|
||||
}
|
||||
|
||||
void BIO_clear_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags &= ~flags;
|
||||
}
|
||||
{
|
||||
b->flags &= ~flags;
|
||||
}
|
||||
|
||||
int BIO_test_flags(const BIO *b, int flags)
|
||||
{
|
||||
return (b->flags & flags);
|
||||
}
|
||||
int BIO_test_flags(const BIO *b, int flags)
|
||||
{
|
||||
return (b->flags & flags);
|
||||
}
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags |= flags;
|
||||
}
|
||||
void BIO_set_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags |= flags;
|
||||
}
|
||||
|
||||
long (*BIO_get_callback(const BIO *b))(struct bio_st *,int,const char *,int, long,long)
|
||||
{
|
||||
return b->callback;
|
||||
}
|
||||
long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,
|
||||
int, long, long) {
|
||||
return b->callback;
|
||||
}
|
||||
|
||||
void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *,int,const char *,int, long,long))
|
||||
{
|
||||
b->callback = cb;
|
||||
}
|
||||
void BIO_set_callback(BIO *b,
|
||||
long (*cb) (struct bio_st *, int, const char *, int,
|
||||
long, long))
|
||||
{
|
||||
b->callback = cb;
|
||||
}
|
||||
|
||||
void BIO_set_callback_arg(BIO *b, char *arg)
|
||||
{
|
||||
b->cb_arg = arg;
|
||||
}
|
||||
{
|
||||
b->cb_arg = arg;
|
||||
}
|
||||
|
||||
char * BIO_get_callback_arg(const BIO *b)
|
||||
{
|
||||
return b->cb_arg;
|
||||
}
|
||||
char *BIO_get_callback_arg(const BIO *b)
|
||||
{
|
||||
return b->cb_arg;
|
||||
}
|
||||
|
||||
const char * BIO_method_name(const BIO *b)
|
||||
{
|
||||
return b->method->name;
|
||||
}
|
||||
const char *BIO_method_name(const BIO *b)
|
||||
{
|
||||
return b->method->name;
|
||||
}
|
||||
|
||||
int BIO_method_type(const BIO *b)
|
||||
{
|
||||
return b->method->type;
|
||||
}
|
||||
|
||||
{
|
||||
return b->method->type;
|
||||
}
|
||||
|
||||
int BIO_read(BIO *b, void *out, int outl)
|
||||
{
|
||||
int i;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
{
|
||||
int i;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_READ,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
|
||||
BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
cb=b->callback;
|
||||
if ((cb != NULL) &&
|
||||
((i=(int)cb(b,BIO_CB_READ,out,outl,0L,1L)) <= 0))
|
||||
return(i);
|
||||
cb = b->callback;
|
||||
if ((cb != NULL) &&
|
||||
((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0))
|
||||
return (i);
|
||||
|
||||
if (!b->init)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_READ,BIO_R_UNINITIALIZED);
|
||||
return(-2);
|
||||
}
|
||||
if (!b->init) {
|
||||
BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
i=b->method->bread(b,out,outl);
|
||||
i = b->method->bread(b, out, outl);
|
||||
|
||||
if (i > 0) b->num_read+=(unsigned long)i;
|
||||
if (i > 0)
|
||||
b->num_read += (unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_READ|BIO_CB_RETURN,out,outl,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
}
|
||||
if (cb != NULL)
|
||||
i = (int)cb(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, 0L, (long)i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int BIO_write(BIO *b, const void *in, int inl)
|
||||
{
|
||||
int i;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
{
|
||||
int i;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if (b == NULL)
|
||||
return(0);
|
||||
if (b == NULL)
|
||||
return (0);
|
||||
|
||||
cb=b->callback;
|
||||
if ((b->method == NULL) || (b->method->bwrite == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_WRITE,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
cb = b->callback;
|
||||
if ((b->method == NULL) || (b->method->bwrite == NULL)) {
|
||||
BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
if ((cb != NULL) &&
|
||||
((i=(int)cb(b,BIO_CB_WRITE,in,inl,0L,1L)) <= 0))
|
||||
return(i);
|
||||
if ((cb != NULL) &&
|
||||
((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0))
|
||||
return (i);
|
||||
|
||||
if (!b->init)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_WRITE,BIO_R_UNINITIALIZED);
|
||||
return(-2);
|
||||
}
|
||||
if (!b->init) {
|
||||
BIOerr(BIO_F_BIO_WRITE, BIO_R_UNINITIALIZED);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
i=b->method->bwrite(b,in,inl);
|
||||
i = b->method->bwrite(b, in, inl);
|
||||
|
||||
if (i > 0) b->num_write+=(unsigned long)i;
|
||||
if (i > 0)
|
||||
b->num_write += (unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
}
|
||||
if (cb != NULL)
|
||||
i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int BIO_puts(BIO *b, const char *in)
|
||||
{
|
||||
int i;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
{
|
||||
int i;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_PUTS,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
|
||||
BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
cb=b->callback;
|
||||
cb = b->callback;
|
||||
|
||||
if ((cb != NULL) &&
|
||||
((i=(int)cb(b,BIO_CB_PUTS,in,0,0L,1L)) <= 0))
|
||||
return(i);
|
||||
if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
|
||||
return (i);
|
||||
|
||||
if (!b->init)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_PUTS,BIO_R_UNINITIALIZED);
|
||||
return(-2);
|
||||
}
|
||||
if (!b->init) {
|
||||
BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
i=b->method->bputs(b,in);
|
||||
i = b->method->bputs(b, in);
|
||||
|
||||
if (i > 0) b->num_write+=(unsigned long)i;
|
||||
if (i > 0)
|
||||
b->num_write += (unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_PUTS|BIO_CB_RETURN,in,0,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
}
|
||||
if (cb != NULL)
|
||||
i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int BIO_gets(BIO *b, char *in, int inl)
|
||||
{
|
||||
int i;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
{
|
||||
int i;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_GETS,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) {
|
||||
BIOerr(BIO_F_BIO_GETS, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
cb=b->callback;
|
||||
cb = b->callback;
|
||||
|
||||
if ((cb != NULL) &&
|
||||
((i=(int)cb(b,BIO_CB_GETS,in,inl,0L,1L)) <= 0))
|
||||
return(i);
|
||||
if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_GETS, in, inl, 0L, 1L)) <= 0))
|
||||
return (i);
|
||||
|
||||
if (!b->init)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_GETS,BIO_R_UNINITIALIZED);
|
||||
return(-2);
|
||||
}
|
||||
if (!b->init) {
|
||||
BIOerr(BIO_F_BIO_GETS, BIO_R_UNINITIALIZED);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
i=b->method->bgets(b,in,inl);
|
||||
i = b->method->bgets(b, in, inl);
|
||||
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_GETS|BIO_CB_RETURN,in,inl,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
}
|
||||
if (cb != NULL)
|
||||
i = (int)cb(b, BIO_CB_GETS | BIO_CB_RETURN, in, inl, 0L, (long)i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int BIO_indent(BIO *b,int indent,int max)
|
||||
{
|
||||
if(indent < 0)
|
||||
indent=0;
|
||||
if(indent > max)
|
||||
indent=max;
|
||||
while(indent--)
|
||||
if(BIO_puts(b," ") != 1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
int BIO_indent(BIO *b, int indent, int max)
|
||||
{
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
if (indent > max)
|
||||
indent = max;
|
||||
while (indent--)
|
||||
if (BIO_puts(b, " ") != 1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg)
|
||||
{
|
||||
int i;
|
||||
{
|
||||
int i;
|
||||
|
||||
i=iarg;
|
||||
return(BIO_ctrl(b,cmd,larg,(char *)&i));
|
||||
}
|
||||
i = iarg;
|
||||
return (BIO_ctrl(b, cmd, larg, (char *)&i));
|
||||
}
|
||||
|
||||
char *BIO_ptr_ctrl(BIO *b, int cmd, long larg)
|
||||
{
|
||||
char *p=NULL;
|
||||
{
|
||||
char *p = NULL;
|
||||
|
||||
if (BIO_ctrl(b,cmd,larg,(char *)&p) <= 0)
|
||||
return(NULL);
|
||||
else
|
||||
return(p);
|
||||
}
|
||||
if (BIO_ctrl(b, cmd, larg, (char *)&p) <= 0)
|
||||
return (NULL);
|
||||
else
|
||||
return (p);
|
||||
}
|
||||
|
||||
long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
|
||||
{
|
||||
long ret;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
{
|
||||
long ret;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if (b == NULL) return(0);
|
||||
if (b == NULL)
|
||||
return (0);
|
||||
|
||||
if ((b->method == NULL) || (b->method->ctrl == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
if ((b->method == NULL) || (b->method->ctrl == NULL)) {
|
||||
BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
cb=b->callback;
|
||||
cb = b->callback;
|
||||
|
||||
if ((cb != NULL) &&
|
||||
((ret=cb(b,BIO_CB_CTRL,parg,cmd,larg,1L)) <= 0))
|
||||
return(ret);
|
||||
if ((cb != NULL) &&
|
||||
((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0))
|
||||
return (ret);
|
||||
|
||||
ret=b->method->ctrl(b,cmd,larg,parg);
|
||||
ret = b->method->ctrl(b, cmd, larg, parg);
|
||||
|
||||
if (cb != NULL)
|
||||
ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd,
|
||||
larg,ret);
|
||||
return(ret);
|
||||
}
|
||||
if (cb != NULL)
|
||||
ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long))
|
||||
{
|
||||
long ret;
|
||||
long (*cb)(BIO *,int,const char *,int,long,long);
|
||||
long BIO_callback_ctrl(BIO *b, int cmd,
|
||||
void (*fp) (struct bio_st *, int, const char *, int,
|
||||
long, long))
|
||||
{
|
||||
long ret;
|
||||
long (*cb) (BIO *, int, const char *, int, long, long);
|
||||
|
||||
if (b == NULL) return(0);
|
||||
if (b == NULL)
|
||||
return (0);
|
||||
|
||||
if ((b->method == NULL) || (b->method->callback_ctrl == NULL))
|
||||
{
|
||||
BIOerr(BIO_F_BIO_CALLBACK_CTRL,BIO_R_UNSUPPORTED_METHOD);
|
||||
return(-2);
|
||||
}
|
||||
if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) {
|
||||
BIOerr(BIO_F_BIO_CALLBACK_CTRL, BIO_R_UNSUPPORTED_METHOD);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
cb=b->callback;
|
||||
cb = b->callback;
|
||||
|
||||
if ((cb != NULL) &&
|
||||
((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0))
|
||||
return(ret);
|
||||
if ((cb != NULL) &&
|
||||
((ret = cb(b, BIO_CB_CTRL, (void *)&fp, cmd, 0, 1L)) <= 0))
|
||||
return (ret);
|
||||
|
||||
ret=b->method->callback_ctrl(b,cmd,fp);
|
||||
ret = b->method->callback_ctrl(b, cmd, fp);
|
||||
|
||||
if (cb != NULL)
|
||||
ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd,
|
||||
0,ret);
|
||||
return(ret);
|
||||
}
|
||||
if (cb != NULL)
|
||||
ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, (void *)&fp, cmd, 0, ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros
|
||||
/*
|
||||
* It is unfortunate to duplicate in functions what the BIO_(w)pending macros
|
||||
* do; but those macros have inappropriate return type, and for interfacing
|
||||
* from other programming languages, C macros aren't much of a help anyway. */
|
||||
* from other programming languages, C macros aren't much of a help anyway.
|
||||
*/
|
||||
size_t BIO_ctrl_pending(BIO *bio)
|
||||
{
|
||||
return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL);
|
||||
}
|
||||
{
|
||||
return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL);
|
||||
}
|
||||
|
||||
size_t BIO_ctrl_wpending(BIO *bio)
|
||||
{
|
||||
return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL);
|
||||
}
|
||||
|
||||
{
|
||||
return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL);
|
||||
}
|
||||
|
||||
/* put the 'bio' on the end of b's list of operators */
|
||||
BIO *BIO_push(BIO *b, BIO *bio)
|
||||
{
|
||||
BIO *lb;
|
||||
{
|
||||
BIO *lb;
|
||||
|
||||
if (b == NULL) return(bio);
|
||||
lb=b;
|
||||
while (lb->next_bio != NULL)
|
||||
lb=lb->next_bio;
|
||||
lb->next_bio=bio;
|
||||
if (bio != NULL)
|
||||
bio->prev_bio=lb;
|
||||
/* called to do internal processing */
|
||||
BIO_ctrl(b,BIO_CTRL_PUSH,0,lb);
|
||||
return(b);
|
||||
}
|
||||
if (b == NULL)
|
||||
return (bio);
|
||||
lb = b;
|
||||
while (lb->next_bio != NULL)
|
||||
lb = lb->next_bio;
|
||||
lb->next_bio = bio;
|
||||
if (bio != NULL)
|
||||
bio->prev_bio = lb;
|
||||
/* called to do internal processing */
|
||||
BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb);
|
||||
return (b);
|
||||
}
|
||||
|
||||
/* Remove the first and return the rest */
|
||||
BIO *BIO_pop(BIO *b)
|
||||
{
|
||||
BIO *ret;
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
if (b == NULL) return(NULL);
|
||||
ret=b->next_bio;
|
||||
if (b == NULL)
|
||||
return (NULL);
|
||||
ret = b->next_bio;
|
||||
|
||||
BIO_ctrl(b,BIO_CTRL_POP,0,b);
|
||||
BIO_ctrl(b, BIO_CTRL_POP, 0, b);
|
||||
|
||||
if (b->prev_bio != NULL)
|
||||
b->prev_bio->next_bio=b->next_bio;
|
||||
if (b->next_bio != NULL)
|
||||
b->next_bio->prev_bio=b->prev_bio;
|
||||
if (b->prev_bio != NULL)
|
||||
b->prev_bio->next_bio = b->next_bio;
|
||||
if (b->next_bio != NULL)
|
||||
b->next_bio->prev_bio = b->prev_bio;
|
||||
|
||||
b->next_bio=NULL;
|
||||
b->prev_bio=NULL;
|
||||
return(ret);
|
||||
}
|
||||
b->next_bio = NULL;
|
||||
b->prev_bio = NULL;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
BIO *BIO_get_retry_BIO(BIO *bio, int *reason)
|
||||
{
|
||||
BIO *b,*last;
|
||||
{
|
||||
BIO *b, *last;
|
||||
|
||||
b=last=bio;
|
||||
for (;;)
|
||||
{
|
||||
if (!BIO_should_retry(b)) break;
|
||||
last=b;
|
||||
b=b->next_bio;
|
||||
if (b == NULL) break;
|
||||
}
|
||||
if (reason != NULL) *reason=last->retry_reason;
|
||||
return(last);
|
||||
}
|
||||
b = last = bio;
|
||||
for (;;) {
|
||||
if (!BIO_should_retry(b))
|
||||
break;
|
||||
last = b;
|
||||
b = b->next_bio;
|
||||
if (b == NULL)
|
||||
break;
|
||||
}
|
||||
if (reason != NULL)
|
||||
*reason = last->retry_reason;
|
||||
return (last);
|
||||
}
|
||||
|
||||
int BIO_get_retry_reason(BIO *bio)
|
||||
{
|
||||
return(bio->retry_reason);
|
||||
}
|
||||
{
|
||||
return (bio->retry_reason);
|
||||
}
|
||||
|
||||
BIO *BIO_find_type(BIO *bio, int type)
|
||||
{
|
||||
int mt,mask;
|
||||
{
|
||||
int mt, mask;
|
||||
|
||||
if(!bio) return NULL;
|
||||
mask=type&0xff;
|
||||
do {
|
||||
if (bio->method != NULL)
|
||||
{
|
||||
mt=bio->method->type;
|
||||
if (!bio)
|
||||
return NULL;
|
||||
mask = type & 0xff;
|
||||
do {
|
||||
if (bio->method != NULL) {
|
||||
mt = bio->method->type;
|
||||
|
||||
if (!mask)
|
||||
{
|
||||
if (mt & type) return(bio);
|
||||
}
|
||||
else if (mt == type)
|
||||
return(bio);
|
||||
}
|
||||
bio=bio->next_bio;
|
||||
} while (bio != NULL);
|
||||
return(NULL);
|
||||
}
|
||||
if (!mask) {
|
||||
if (mt & type)
|
||||
return (bio);
|
||||
} else if (mt == type)
|
||||
return (bio);
|
||||
}
|
||||
bio = bio->next_bio;
|
||||
} while (bio != NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
BIO *BIO_next(BIO *b)
|
||||
{
|
||||
if(!b) return NULL;
|
||||
return b->next_bio;
|
||||
}
|
||||
{
|
||||
if (!b)
|
||||
return NULL;
|
||||
return b->next_bio;
|
||||
}
|
||||
|
||||
void BIO_free_all(BIO *bio)
|
||||
{
|
||||
BIO *b;
|
||||
int ref;
|
||||
{
|
||||
BIO *b;
|
||||
int ref;
|
||||
|
||||
while (bio != NULL)
|
||||
{
|
||||
b=bio;
|
||||
ref=b->references;
|
||||
bio=bio->next_bio;
|
||||
BIO_free(b);
|
||||
/* Since ref count > 1, don't free anyone else. */
|
||||
if (ref > 1) break;
|
||||
}
|
||||
}
|
||||
while (bio != NULL) {
|
||||
b = bio;
|
||||
ref = b->references;
|
||||
bio = bio->next_bio;
|
||||
BIO_free(b);
|
||||
/* Since ref count > 1, don't free anyone else. */
|
||||
if (ref > 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BIO *BIO_dup_chain(BIO *in)
|
||||
{
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new;
|
||||
{
|
||||
BIO *ret = NULL, *eoc = NULL, *bio, *new_bio;
|
||||
|
||||
for (bio=in; bio != NULL; bio=bio->next_bio)
|
||||
{
|
||||
if ((new=BIO_new(bio->method)) == NULL) goto err;
|
||||
new->callback=bio->callback;
|
||||
new->cb_arg=bio->cb_arg;
|
||||
new->init=bio->init;
|
||||
new->shutdown=bio->shutdown;
|
||||
new->flags=bio->flags;
|
||||
for (bio = in; bio != NULL; bio = bio->next_bio) {
|
||||
if ((new_bio = BIO_new(bio->method)) == NULL)
|
||||
goto err;
|
||||
new_bio->callback = bio->callback;
|
||||
new_bio->cb_arg = bio->cb_arg;
|
||||
new_bio->init = bio->init;
|
||||
new_bio->shutdown = bio->shutdown;
|
||||
new_bio->flags = bio->flags;
|
||||
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new->num=bio->num;
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new_bio->num = bio->num;
|
||||
|
||||
if (!BIO_dup_state(bio,(char *)new))
|
||||
{
|
||||
BIO_free(new);
|
||||
goto err;
|
||||
}
|
||||
if (!BIO_dup_state(bio, (char *)new_bio)) {
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
|
||||
&bio->ex_data))
|
||||
goto err;
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
|
||||
&bio->ex_data)) {
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
eoc=new;
|
||||
ret=eoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_push(eoc,new);
|
||||
eoc=new;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
err:
|
||||
if (ret != NULL)
|
||||
BIO_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
if (ret == NULL) {
|
||||
eoc = new_bio;
|
||||
ret = eoc;
|
||||
} else {
|
||||
BIO_push(eoc, new_bio);
|
||||
eoc = new_bio;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
err:
|
||||
BIO_free_all(ret);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void BIO_copy_next_retry(BIO *b)
|
||||
{
|
||||
BIO_set_flags(b,BIO_get_retry_flags(b->next_bio));
|
||||
b->retry_reason=b->next_bio->retry_reason;
|
||||
}
|
||||
{
|
||||
BIO_set_flags(b, BIO_get_retry_flags(b->next_bio));
|
||||
b->retry_reason = b->next_bio->retry_reason;
|
||||
}
|
||||
|
||||
int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
|
||||
{
|
||||
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, argl, argp,
|
||||
new_func, dup_func, free_func);
|
||||
}
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
|
||||
{
|
||||
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, argl, argp,
|
||||
new_func, dup_func, free_func);
|
||||
}
|
||||
|
||||
int BIO_set_ex_data(BIO *bio, int idx, void *data)
|
||||
{
|
||||
return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data));
|
||||
}
|
||||
{
|
||||
return (CRYPTO_set_ex_data(&(bio->ex_data), idx, data));
|
||||
}
|
||||
|
||||
void *BIO_get_ex_data(BIO *bio, int idx)
|
||||
{
|
||||
return(CRYPTO_get_ex_data(&(bio->ex_data),idx));
|
||||
}
|
||||
{
|
||||
return (CRYPTO_get_ex_data(&(bio->ex_data), idx));
|
||||
}
|
||||
|
||||
unsigned long BIO_number_read(BIO *bio)
|
||||
{
|
||||
if(bio) return bio->num_read;
|
||||
return 0;
|
||||
if (bio)
|
||||
return bio->num_read;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long BIO_number_written(BIO *bio)
|
||||
{
|
||||
if(bio) return bio->num_write;
|
||||
return 0;
|
||||
if (bio)
|
||||
return bio->num_write;
|
||||
return 0;
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(BIO)
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -64,33 +64,32 @@
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
||||
#ifdef OPENSSL_SYS_WIN16
|
||||
#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
|
||||
#else
|
||||
#define SOCKET_PROTOCOL IPPROTO_TCP
|
||||
#endif
|
||||
# ifdef OPENSSL_SYS_WIN16
|
||||
# define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
|
||||
# else
|
||||
# define SOCKET_PROTOCOL IPPROTO_TCP
|
||||
# endif
|
||||
|
||||
#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
|
||||
# if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
|
||||
/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
|
||||
#undef FIONBIO
|
||||
#endif
|
||||
# undef FIONBIO
|
||||
# endif
|
||||
|
||||
typedef struct bio_accept_st
|
||||
{
|
||||
int state;
|
||||
char *param_addr;
|
||||
|
||||
int accept_sock;
|
||||
int accept_nbio;
|
||||
|
||||
char *addr;
|
||||
int nbio;
|
||||
/* If 0, it means normal, if 1, do a connect on bind failure,
|
||||
* and if there is no-one listening, bind with SO_REUSEADDR.
|
||||
* If 2, always use SO_REUSEADDR. */
|
||||
int bind_mode;
|
||||
BIO *bio_chain;
|
||||
} BIO_ACCEPT;
|
||||
typedef struct bio_accept_st {
|
||||
int state;
|
||||
char *param_addr;
|
||||
int accept_sock;
|
||||
int accept_nbio;
|
||||
char *addr;
|
||||
int nbio;
|
||||
/*
|
||||
* If 0, it means normal, if 1, do a connect on bind failure, and if
|
||||
* there is no-one listening, bind with SO_REUSEADDR. If 2, always use
|
||||
* SO_REUSEADDR.
|
||||
*/
|
||||
int bind_mode;
|
||||
BIO *bio_chain;
|
||||
} BIO_ACCEPT;
|
||||
|
||||
static int acpt_write(BIO *h, const char *buf, int num);
|
||||
static int acpt_read(BIO *h, char *buf, int size);
|
||||
@@ -100,379 +99,365 @@ static int acpt_new(BIO *h);
|
||||
static int acpt_free(BIO *data);
|
||||
static int acpt_state(BIO *b, BIO_ACCEPT *c);
|
||||
static void acpt_close_socket(BIO *data);
|
||||
static BIO_ACCEPT *BIO_ACCEPT_new(void );
|
||||
static BIO_ACCEPT *BIO_ACCEPT_new(void);
|
||||
static void BIO_ACCEPT_free(BIO_ACCEPT *a);
|
||||
|
||||
#define ACPT_S_BEFORE 1
|
||||
#define ACPT_S_GET_ACCEPT_SOCKET 2
|
||||
#define ACPT_S_OK 3
|
||||
# define ACPT_S_BEFORE 1
|
||||
# define ACPT_S_GET_ACCEPT_SOCKET 2
|
||||
# define ACPT_S_OK 3
|
||||
|
||||
static BIO_METHOD methods_acceptp=
|
||||
{
|
||||
BIO_TYPE_ACCEPT,
|
||||
"socket accept",
|
||||
acpt_write,
|
||||
acpt_read,
|
||||
acpt_puts,
|
||||
NULL, /* connect_gets, */
|
||||
acpt_ctrl,
|
||||
acpt_new,
|
||||
acpt_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD methods_acceptp = {
|
||||
BIO_TYPE_ACCEPT,
|
||||
"socket accept",
|
||||
acpt_write,
|
||||
acpt_read,
|
||||
acpt_puts,
|
||||
NULL, /* connect_gets, */
|
||||
acpt_ctrl,
|
||||
acpt_new,
|
||||
acpt_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_accept(void)
|
||||
{
|
||||
return(&methods_acceptp);
|
||||
}
|
||||
{
|
||||
return (&methods_acceptp);
|
||||
}
|
||||
|
||||
static int acpt_new(BIO *bi)
|
||||
{
|
||||
BIO_ACCEPT *ba;
|
||||
{
|
||||
BIO_ACCEPT *ba;
|
||||
|
||||
bi->init=0;
|
||||
bi->num=INVALID_SOCKET;
|
||||
bi->flags=0;
|
||||
if ((ba=BIO_ACCEPT_new()) == NULL)
|
||||
return(0);
|
||||
bi->ptr=(char *)ba;
|
||||
ba->state=ACPT_S_BEFORE;
|
||||
bi->shutdown=1;
|
||||
return(1);
|
||||
}
|
||||
bi->init = 0;
|
||||
bi->num = INVALID_SOCKET;
|
||||
bi->flags = 0;
|
||||
if ((ba = BIO_ACCEPT_new()) == NULL)
|
||||
return (0);
|
||||
bi->ptr = (char *)ba;
|
||||
ba->state = ACPT_S_BEFORE;
|
||||
bi->shutdown = 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static BIO_ACCEPT *BIO_ACCEPT_new(void)
|
||||
{
|
||||
BIO_ACCEPT *ret;
|
||||
{
|
||||
BIO_ACCEPT *ret;
|
||||
|
||||
if ((ret=(BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
|
||||
return(NULL);
|
||||
if ((ret = (BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
|
||||
return (NULL);
|
||||
|
||||
memset(ret,0,sizeof(BIO_ACCEPT));
|
||||
ret->accept_sock=INVALID_SOCKET;
|
||||
ret->bind_mode=BIO_BIND_NORMAL;
|
||||
return(ret);
|
||||
}
|
||||
memset(ret, 0, sizeof(BIO_ACCEPT));
|
||||
ret->accept_sock = INVALID_SOCKET;
|
||||
ret->bind_mode = BIO_BIND_NORMAL;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static void BIO_ACCEPT_free(BIO_ACCEPT *a)
|
||||
{
|
||||
if(a == NULL)
|
||||
return;
|
||||
{
|
||||
if (a == NULL)
|
||||
return;
|
||||
|
||||
if (a->param_addr != NULL) OPENSSL_free(a->param_addr);
|
||||
if (a->addr != NULL) OPENSSL_free(a->addr);
|
||||
if (a->bio_chain != NULL) BIO_free(a->bio_chain);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
if (a->param_addr != NULL)
|
||||
OPENSSL_free(a->param_addr);
|
||||
if (a->addr != NULL)
|
||||
OPENSSL_free(a->addr);
|
||||
if (a->bio_chain != NULL)
|
||||
BIO_free(a->bio_chain);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
static void acpt_close_socket(BIO *bio)
|
||||
{
|
||||
BIO_ACCEPT *c;
|
||||
{
|
||||
BIO_ACCEPT *c;
|
||||
|
||||
c=(BIO_ACCEPT *)bio->ptr;
|
||||
if (c->accept_sock != INVALID_SOCKET)
|
||||
{
|
||||
shutdown(c->accept_sock,2);
|
||||
closesocket(c->accept_sock);
|
||||
c->accept_sock=INVALID_SOCKET;
|
||||
bio->num=INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
c = (BIO_ACCEPT *)bio->ptr;
|
||||
if (c->accept_sock != INVALID_SOCKET) {
|
||||
shutdown(c->accept_sock, 2);
|
||||
closesocket(c->accept_sock);
|
||||
c->accept_sock = INVALID_SOCKET;
|
||||
bio->num = INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
|
||||
static int acpt_free(BIO *a)
|
||||
{
|
||||
BIO_ACCEPT *data;
|
||||
{
|
||||
BIO_ACCEPT *data;
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
data = (BIO_ACCEPT *)a->ptr;
|
||||
|
||||
if (a->shutdown) {
|
||||
acpt_close_socket(a);
|
||||
BIO_ACCEPT_free(data);
|
||||
a->ptr = NULL;
|
||||
a->flags = 0;
|
||||
a->init = 0;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (a == NULL) return(0);
|
||||
data=(BIO_ACCEPT *)a->ptr;
|
||||
|
||||
if (a->shutdown)
|
||||
{
|
||||
acpt_close_socket(a);
|
||||
BIO_ACCEPT_free(data);
|
||||
a->ptr=NULL;
|
||||
a->flags=0;
|
||||
a->init=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int acpt_state(BIO *b, BIO_ACCEPT *c)
|
||||
{
|
||||
BIO *bio=NULL,*dbio;
|
||||
int s= -1;
|
||||
int i;
|
||||
{
|
||||
BIO *bio = NULL, *dbio;
|
||||
int s = -1;
|
||||
int i;
|
||||
|
||||
again:
|
||||
switch (c->state)
|
||||
{
|
||||
case ACPT_S_BEFORE:
|
||||
if (c->param_addr == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_NO_ACCEPT_PORT_SPECIFIED);
|
||||
return(-1);
|
||||
}
|
||||
s=BIO_get_accept_socket(c->param_addr,c->bind_mode);
|
||||
if (s == INVALID_SOCKET)
|
||||
return(-1);
|
||||
again:
|
||||
switch (c->state) {
|
||||
case ACPT_S_BEFORE:
|
||||
if (c->param_addr == NULL) {
|
||||
BIOerr(BIO_F_ACPT_STATE, BIO_R_NO_ACCEPT_PORT_SPECIFIED);
|
||||
return (-1);
|
||||
}
|
||||
s = BIO_get_accept_socket(c->param_addr, c->bind_mode);
|
||||
if (s == INVALID_SOCKET)
|
||||
return (-1);
|
||||
|
||||
if (c->accept_nbio)
|
||||
{
|
||||
if (!BIO_socket_nbio(s,1))
|
||||
{
|
||||
closesocket(s);
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
c->accept_sock=s;
|
||||
b->num=s;
|
||||
c->state=ACPT_S_GET_ACCEPT_SOCKET;
|
||||
return(1);
|
||||
/* break; */
|
||||
case ACPT_S_GET_ACCEPT_SOCKET:
|
||||
if (b->next_bio != NULL)
|
||||
{
|
||||
c->state=ACPT_S_OK;
|
||||
goto again;
|
||||
}
|
||||
BIO_clear_retry_flags(b);
|
||||
b->retry_reason=0;
|
||||
i=BIO_accept(c->accept_sock,&(c->addr));
|
||||
if (c->accept_nbio) {
|
||||
if (!BIO_socket_nbio(s, 1)) {
|
||||
closesocket(s);
|
||||
BIOerr(BIO_F_ACPT_STATE,
|
||||
BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
c->accept_sock = s;
|
||||
b->num = s;
|
||||
c->state = ACPT_S_GET_ACCEPT_SOCKET;
|
||||
return (1);
|
||||
/* break; */
|
||||
case ACPT_S_GET_ACCEPT_SOCKET:
|
||||
if (b->next_bio != NULL) {
|
||||
c->state = ACPT_S_OK;
|
||||
goto again;
|
||||
}
|
||||
BIO_clear_retry_flags(b);
|
||||
b->retry_reason = 0;
|
||||
i = BIO_accept(c->accept_sock, &(c->addr));
|
||||
|
||||
/* -2 return means we should retry */
|
||||
if(i == -2)
|
||||
{
|
||||
BIO_set_retry_special(b);
|
||||
b->retry_reason=BIO_RR_ACCEPT;
|
||||
return -1;
|
||||
}
|
||||
/* -2 return means we should retry */
|
||||
if (i == -2) {
|
||||
BIO_set_retry_special(b);
|
||||
b->retry_reason = BIO_RR_ACCEPT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (i < 0) return(i);
|
||||
if (i < 0)
|
||||
return (i);
|
||||
|
||||
bio=BIO_new_socket(i,BIO_CLOSE);
|
||||
if (bio == NULL) goto err;
|
||||
bio = BIO_new_socket(i, BIO_CLOSE);
|
||||
if (bio == NULL)
|
||||
goto err;
|
||||
|
||||
BIO_set_callback(bio,BIO_get_callback(b));
|
||||
BIO_set_callback_arg(bio,BIO_get_callback_arg(b));
|
||||
BIO_set_callback(bio, BIO_get_callback(b));
|
||||
BIO_set_callback_arg(bio, BIO_get_callback_arg(b));
|
||||
|
||||
if (c->nbio)
|
||||
{
|
||||
if (!BIO_socket_nbio(i,1))
|
||||
{
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (c->nbio) {
|
||||
if (!BIO_socket_nbio(i, 1)) {
|
||||
BIOerr(BIO_F_ACPT_STATE,
|
||||
BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the accept BIO has an bio_chain, we dup it and
|
||||
* put the new socket at the end. */
|
||||
if (c->bio_chain != NULL)
|
||||
{
|
||||
if ((dbio=BIO_dup_chain(c->bio_chain)) == NULL)
|
||||
goto err;
|
||||
if (!BIO_push(dbio,bio)) goto err;
|
||||
bio=dbio;
|
||||
}
|
||||
if (BIO_push(b,bio) == NULL) goto err;
|
||||
/*
|
||||
* If the accept BIO has an bio_chain, we dup it and put the new
|
||||
* socket at the end.
|
||||
*/
|
||||
if (c->bio_chain != NULL) {
|
||||
if ((dbio = BIO_dup_chain(c->bio_chain)) == NULL)
|
||||
goto err;
|
||||
if (!BIO_push(dbio, bio))
|
||||
goto err;
|
||||
bio = dbio;
|
||||
}
|
||||
if (BIO_push(b, bio) == NULL)
|
||||
goto err;
|
||||
|
||||
c->state=ACPT_S_OK;
|
||||
return(1);
|
||||
err:
|
||||
if (bio != NULL)
|
||||
BIO_free(bio);
|
||||
else if (s >= 0)
|
||||
closesocket(s);
|
||||
return(0);
|
||||
/* break; */
|
||||
case ACPT_S_OK:
|
||||
if (b->next_bio == NULL)
|
||||
{
|
||||
c->state=ACPT_S_GET_ACCEPT_SOCKET;
|
||||
goto again;
|
||||
}
|
||||
return(1);
|
||||
/* break; */
|
||||
default:
|
||||
return(0);
|
||||
/* break; */
|
||||
}
|
||||
c->state = ACPT_S_OK;
|
||||
return (1);
|
||||
err:
|
||||
if (bio != NULL)
|
||||
BIO_free(bio);
|
||||
else if (s >= 0)
|
||||
closesocket(s);
|
||||
return (0);
|
||||
/* break; */
|
||||
case ACPT_S_OK:
|
||||
if (b->next_bio == NULL) {
|
||||
c->state = ACPT_S_GET_ACCEPT_SOCKET;
|
||||
goto again;
|
||||
}
|
||||
return (1);
|
||||
/* break; */
|
||||
default:
|
||||
return (0);
|
||||
/* break; */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int acpt_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
BIO_ACCEPT *data;
|
||||
{
|
||||
int ret = 0;
|
||||
BIO_ACCEPT *data;
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
data=(BIO_ACCEPT *)b->ptr;
|
||||
BIO_clear_retry_flags(b);
|
||||
data = (BIO_ACCEPT *)b->ptr;
|
||||
|
||||
while (b->next_bio == NULL)
|
||||
{
|
||||
ret=acpt_state(b,data);
|
||||
if (ret <= 0) return(ret);
|
||||
}
|
||||
while (b->next_bio == NULL) {
|
||||
ret = acpt_state(b, data);
|
||||
if (ret <= 0)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ret=BIO_read(b->next_bio,out,outl);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
ret = BIO_read(b->next_bio, out, outl);
|
||||
BIO_copy_next_retry(b);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int acpt_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret;
|
||||
BIO_ACCEPT *data;
|
||||
{
|
||||
int ret;
|
||||
BIO_ACCEPT *data;
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
data=(BIO_ACCEPT *)b->ptr;
|
||||
BIO_clear_retry_flags(b);
|
||||
data = (BIO_ACCEPT *)b->ptr;
|
||||
|
||||
while (b->next_bio == NULL)
|
||||
{
|
||||
ret=acpt_state(b,data);
|
||||
if (ret <= 0) return(ret);
|
||||
}
|
||||
while (b->next_bio == NULL) {
|
||||
ret = acpt_state(b, data);
|
||||
if (ret <= 0)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ret=BIO_write(b->next_bio,in,inl);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
ret = BIO_write(b->next_bio, in, inl);
|
||||
BIO_copy_next_retry(b);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
int *ip;
|
||||
long ret=1;
|
||||
BIO_ACCEPT *data;
|
||||
char **pp;
|
||||
{
|
||||
int *ip;
|
||||
long ret = 1;
|
||||
BIO_ACCEPT *data;
|
||||
char **pp;
|
||||
|
||||
data=(BIO_ACCEPT *)b->ptr;
|
||||
data = (BIO_ACCEPT *)b->ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
ret=0;
|
||||
data->state=ACPT_S_BEFORE;
|
||||
acpt_close_socket(b);
|
||||
b->flags=0;
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
/* use this one to start the connection */
|
||||
ret=(long)acpt_state(b,data);
|
||||
break;
|
||||
case BIO_C_SET_ACCEPT:
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
b->init=1;
|
||||
if (data->param_addr != NULL)
|
||||
OPENSSL_free(data->param_addr);
|
||||
data->param_addr=BUF_strdup(ptr);
|
||||
}
|
||||
else if (num == 1)
|
||||
{
|
||||
data->accept_nbio=(ptr != NULL);
|
||||
}
|
||||
else if (num == 2)
|
||||
{
|
||||
if (data->bio_chain != NULL)
|
||||
BIO_free(data->bio_chain);
|
||||
data->bio_chain=(BIO *)ptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_NBIO:
|
||||
data->nbio=(int)num;
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
b->init=1;
|
||||
b->num= *((int *)ptr);
|
||||
data->accept_sock=b->num;
|
||||
data->state=ACPT_S_GET_ACCEPT_SOCKET;
|
||||
b->shutdown=(int)num;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init)
|
||||
{
|
||||
ip=(int *)ptr;
|
||||
if (ip != NULL)
|
||||
*ip=data->accept_sock;
|
||||
ret=data->accept_sock;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
break;
|
||||
case BIO_C_GET_ACCEPT:
|
||||
if (b->init)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
pp=(char **)ptr;
|
||||
*pp=data->param_addr;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=0;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
break;
|
||||
case BIO_C_SET_BIND_MODE:
|
||||
data->bind_mode=(int)num;
|
||||
break;
|
||||
case BIO_C_GET_BIND_MODE:
|
||||
ret=(long)data->bind_mode;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
/* dbio=(BIO *)ptr;
|
||||
if (data->param_port) EAY EAY
|
||||
BIO_set_port(dbio,data->param_port);
|
||||
if (data->param_hostname)
|
||||
BIO_set_hostname(dbio,data->param_hostname);
|
||||
BIO_set_nbio(dbio,data->nbio); */
|
||||
break;
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
ret = 0;
|
||||
data->state = ACPT_S_BEFORE;
|
||||
acpt_close_socket(b);
|
||||
b->flags = 0;
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
/* use this one to start the connection */
|
||||
ret = (long)acpt_state(b, data);
|
||||
break;
|
||||
case BIO_C_SET_ACCEPT:
|
||||
if (ptr != NULL) {
|
||||
if (num == 0) {
|
||||
b->init = 1;
|
||||
if (data->param_addr != NULL)
|
||||
OPENSSL_free(data->param_addr);
|
||||
data->param_addr = BUF_strdup(ptr);
|
||||
} else if (num == 1) {
|
||||
data->accept_nbio = (ptr != NULL);
|
||||
} else if (num == 2) {
|
||||
if (data->bio_chain != NULL)
|
||||
BIO_free(data->bio_chain);
|
||||
data->bio_chain = (BIO *)ptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_NBIO:
|
||||
data->nbio = (int)num;
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
b->init = 1;
|
||||
b->num = *((int *)ptr);
|
||||
data->accept_sock = b->num;
|
||||
data->state = ACPT_S_GET_ACCEPT_SOCKET;
|
||||
b->shutdown = (int)num;
|
||||
b->init = 1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init) {
|
||||
ip = (int *)ptr;
|
||||
if (ip != NULL)
|
||||
*ip = data->accept_sock;
|
||||
ret = data->accept_sock;
|
||||
} else
|
||||
ret = -1;
|
||||
break;
|
||||
case BIO_C_GET_ACCEPT:
|
||||
if (b->init) {
|
||||
if (ptr != NULL) {
|
||||
pp = (char **)ptr;
|
||||
*pp = data->param_addr;
|
||||
} else
|
||||
ret = -1;
|
||||
} else
|
||||
ret = -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
break;
|
||||
case BIO_C_SET_BIND_MODE:
|
||||
data->bind_mode = (int)num;
|
||||
break;
|
||||
case BIO_C_GET_BIND_MODE:
|
||||
ret = (long)data->bind_mode;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
/*- dbio=(BIO *)ptr;
|
||||
if (data->param_port) EAY EAY
|
||||
BIO_set_port(dbio,data->param_port);
|
||||
if (data->param_hostname)
|
||||
BIO_set_hostname(dbio,data->param_hostname);
|
||||
BIO_set_nbio(dbio,data->nbio); */
|
||||
break;
|
||||
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int acpt_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
{
|
||||
int n, ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=acpt_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
n = strlen(str);
|
||||
ret = acpt_write(bp, str, n);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_accept(char *str)
|
||||
{
|
||||
BIO *ret;
|
||||
BIO *BIO_new_accept(const char *str)
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
ret=BIO_new(BIO_s_accept());
|
||||
if (ret == NULL) return(NULL);
|
||||
if (BIO_set_accept_port(ret,str))
|
||||
return(ret);
|
||||
else
|
||||
{
|
||||
BIO_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret = BIO_new(BIO_s_accept());
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
if (BIO_set_accept_port(ret, str))
|
||||
return (ret);
|
||||
else {
|
||||
BIO_free(ret);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
1314
crypto/bio/bss_bio.c
1314
crypto/bio/bss_bio.c
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -63,9 +63,27 @@
|
||||
|
||||
#if defined(OPENSSL_NO_POSIX_IO)
|
||||
/*
|
||||
* One can argue that one should implement dummy placeholder for
|
||||
* BIO_s_fd here...
|
||||
* Dummy placeholder for BIO_s_fd...
|
||||
*/
|
||||
BIO *BIO_new_fd(int fd, int close_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int BIO_fd_non_fatal_error(int err)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BIO_fd_should_retry(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIO_METHOD *BIO_s_fd(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* As for unconditional usage of "UPLINK" interface in this module.
|
||||
@@ -79,7 +97,7 @@
|
||||
* file descriptors can only be provided by application. Therefore
|
||||
* "UPLINK" calls are due...
|
||||
*/
|
||||
#include "bio_lcl.h"
|
||||
# include "bio_lcl.h"
|
||||
|
||||
static int fd_write(BIO *h, const char *buf, int num);
|
||||
static int fd_read(BIO *h, char *buf, int size);
|
||||
@@ -90,230 +108,223 @@ static int fd_new(BIO *h);
|
||||
static int fd_free(BIO *data);
|
||||
int BIO_fd_should_retry(int s);
|
||||
|
||||
static BIO_METHOD methods_fdp=
|
||||
{
|
||||
BIO_TYPE_FD,"file descriptor",
|
||||
fd_write,
|
||||
fd_read,
|
||||
fd_puts,
|
||||
fd_gets,
|
||||
fd_ctrl,
|
||||
fd_new,
|
||||
fd_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD methods_fdp = {
|
||||
BIO_TYPE_FD, "file descriptor",
|
||||
fd_write,
|
||||
fd_read,
|
||||
fd_puts,
|
||||
fd_gets,
|
||||
fd_ctrl,
|
||||
fd_new,
|
||||
fd_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_fd(void)
|
||||
{
|
||||
return(&methods_fdp);
|
||||
}
|
||||
{
|
||||
return (&methods_fdp);
|
||||
}
|
||||
|
||||
BIO *BIO_new_fd(int fd,int close_flag)
|
||||
{
|
||||
BIO *ret;
|
||||
ret=BIO_new(BIO_s_fd());
|
||||
if (ret == NULL) return(NULL);
|
||||
BIO_set_fd(ret,fd,close_flag);
|
||||
return(ret);
|
||||
}
|
||||
BIO *BIO_new_fd(int fd, int close_flag)
|
||||
{
|
||||
BIO *ret;
|
||||
ret = BIO_new(BIO_s_fd());
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
BIO_set_fd(ret, fd, close_flag);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int fd_new(BIO *bi)
|
||||
{
|
||||
bi->init=0;
|
||||
bi->num=-1;
|
||||
bi->ptr=NULL;
|
||||
bi->flags=BIO_FLAGS_UPLINK; /* essentially redundant */
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 0;
|
||||
bi->num = -1;
|
||||
bi->ptr = NULL;
|
||||
bi->flags = BIO_FLAGS_UPLINK; /* essentially redundant */
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int fd_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if (a->init)
|
||||
{
|
||||
UP_close(a->num);
|
||||
}
|
||||
a->init=0;
|
||||
a->flags=BIO_FLAGS_UPLINK;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int fd_read(BIO *b, char *out,int outl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->shutdown) {
|
||||
if (a->init) {
|
||||
UP_close(a->num);
|
||||
}
|
||||
a->init = 0;
|
||||
a->flags = BIO_FLAGS_UPLINK;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (out != NULL)
|
||||
{
|
||||
clear_sys_error();
|
||||
ret=UP_read(b->num,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (BIO_fd_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
static int fd_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (out != NULL) {
|
||||
clear_sys_error();
|
||||
ret = UP_read(b->num, out, outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0) {
|
||||
if (BIO_fd_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int fd_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret;
|
||||
clear_sys_error();
|
||||
ret=UP_write(b->num,in,inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (BIO_fd_should_retry(ret))
|
||||
BIO_set_retry_write(b);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
int ret;
|
||||
clear_sys_error();
|
||||
ret = UP_write(b->num, in, inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0) {
|
||||
if (BIO_fd_should_retry(ret))
|
||||
BIO_set_retry_write(b);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
int *ip;
|
||||
{
|
||||
long ret = 1;
|
||||
int *ip;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
num=0;
|
||||
case BIO_C_FILE_SEEK:
|
||||
ret=(long)UP_lseek(b->num,num,0);
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)UP_lseek(b->num,0,1);
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
fd_free(b);
|
||||
b->num= *((int *)ptr);
|
||||
b->shutdown=(int)num;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init)
|
||||
{
|
||||
ip=(int *)ptr;
|
||||
if (ip != NULL) *ip=b->num;
|
||||
ret=b->num;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=0;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret=1;
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
num = 0;
|
||||
case BIO_C_FILE_SEEK:
|
||||
ret = (long)UP_lseek(b->num, num, 0);
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
ret = (long)UP_lseek(b->num, 0, 1);
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
fd_free(b);
|
||||
b->num = *((int *)ptr);
|
||||
b->shutdown = (int)num;
|
||||
b->init = 1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init) {
|
||||
ip = (int *)ptr;
|
||||
if (ip != NULL)
|
||||
*ip = b->num;
|
||||
ret = b->num;
|
||||
} else
|
||||
ret = -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret = 1;
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int fd_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
{
|
||||
int n, ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=fd_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
n = strlen(str);
|
||||
ret = fd_write(bp, str, n);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int fd_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
int ret=0;
|
||||
char *ptr=buf;
|
||||
char *end=buf+size-1;
|
||||
{
|
||||
int ret = 0;
|
||||
char *ptr = buf;
|
||||
char *end = buf + size - 1;
|
||||
|
||||
while ( (ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n') )
|
||||
ptr++;
|
||||
while ((ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n'))
|
||||
ptr++;
|
||||
|
||||
ptr[0]='\0';
|
||||
ptr[0] = '\0';
|
||||
|
||||
if (buf[0] != '\0')
|
||||
ret=strlen(buf);
|
||||
return(ret);
|
||||
}
|
||||
if (buf[0] != '\0')
|
||||
ret = strlen(buf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int BIO_fd_should_retry(int i)
|
||||
{
|
||||
int err;
|
||||
{
|
||||
int err;
|
||||
|
||||
if ((i == 0) || (i == -1))
|
||||
{
|
||||
err=get_last_sys_error();
|
||||
if ((i == 0) || (i == -1)) {
|
||||
err = get_last_sys_error();
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
|
||||
if ((i == -1) && (err == 0))
|
||||
return(1);
|
||||
#endif
|
||||
# if defined(OPENSSL_SYS_WINDOWS) && 0/* more microsoft stupidity? perhaps
|
||||
* not? Ben 4/1/99 */
|
||||
if ((i == -1) && (err == 0))
|
||||
return (1);
|
||||
# endif
|
||||
|
||||
return(BIO_fd_non_fatal_error(err));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
return (BIO_fd_non_fatal_error(err));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int BIO_fd_non_fatal_error(int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
{
|
||||
switch (err) {
|
||||
|
||||
#ifdef EWOULDBLOCK
|
||||
# ifdef WSAEWOULDBLOCK
|
||||
# if WSAEWOULDBLOCK != EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
# ifdef EWOULDBLOCK
|
||||
# ifdef WSAEWOULDBLOCK
|
||||
# if WSAEWOULDBLOCK != EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
# else
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
# else
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ENOTCONN)
|
||||
case ENOTCONN:
|
||||
#endif
|
||||
|
||||
#ifdef EINTR
|
||||
case EINTR:
|
||||
#endif
|
||||
|
||||
#ifdef EAGAIN
|
||||
#if EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
# if defined(ENOTCONN)
|
||||
case ENOTCONN:
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef EPROTO
|
||||
case EPROTO:
|
||||
#endif
|
||||
# ifdef EINTR
|
||||
case EINTR:
|
||||
# endif
|
||||
|
||||
#ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
#endif
|
||||
# ifdef EAGAIN
|
||||
# if EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef EALREADY
|
||||
case EALREADY:
|
||||
#endif
|
||||
return(1);
|
||||
/* break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
# ifdef EPROTO
|
||||
case EPROTO:
|
||||
# endif
|
||||
|
||||
# ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
# endif
|
||||
|
||||
# ifdef EALREADY
|
||||
case EALREADY:
|
||||
# endif
|
||||
return (1);
|
||||
/* break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,51 +49,51 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* 03-Dec-1997 rdenny@dc3.com Fix bug preventing use of stdin/stdout
|
||||
* with binary data (e.g. asn1parse -inform DER < xxx) under
|
||||
* Windows
|
||||
/*-
|
||||
* 03-Dec-1997 rdenny@dc3.com Fix bug preventing use of stdin/stdout
|
||||
* with binary data (e.g. asn1parse -inform DER < xxx) under
|
||||
* Windows
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BSS_FILE_C
|
||||
#define HEADER_BSS_FILE_C
|
||||
# define HEADER_BSS_FILE_C
|
||||
|
||||
#if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
/* Following definition aliases fopen to fopen64 on above mentioned
|
||||
* platforms. This makes it possible to open and sequentially access
|
||||
* files larger than 2GB from 32-bit application. It does not allow to
|
||||
* traverse them beyond 2GB with fseek/ftell, but on the other hand *no*
|
||||
* 32-bit platform permits that, not with fseek/ftell. Not to mention
|
||||
* that breaking 2GB limit for seeking would require surgery to *our*
|
||||
* API. But sequential access suffices for practical cases when you
|
||||
* can run into large files, such as fingerprinting, so we can let API
|
||||
* alone. For reference, the list of 32-bit platforms which allow for
|
||||
* sequential access of large files without extra "magic" comprise *BSD,
|
||||
* Darwin, IRIX...
|
||||
# if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
/*
|
||||
* Following definition aliases fopen to fopen64 on above mentioned
|
||||
* platforms. This makes it possible to open and sequentially access files
|
||||
* larger than 2GB from 32-bit application. It does not allow to traverse
|
||||
* them beyond 2GB with fseek/ftell, but on the other hand *no* 32-bit
|
||||
* platform permits that, not with fseek/ftell. Not to mention that breaking
|
||||
* 2GB limit for seeking would require surgery to *our* API. But sequential
|
||||
* access suffices for practical cases when you can run into large files,
|
||||
* such as fingerprinting, so we can let API alone. For reference, the list
|
||||
* of 32-bit platforms which allow for sequential access of large files
|
||||
* without extra "magic" comprise *BSD, Darwin, IRIX...
|
||||
*/
|
||||
#ifndef _FILE_OFFSET_BITS
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
#endif
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bio_lcl.h"
|
||||
#include <openssl/err.h>
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include "cryptlib.h"
|
||||
# include "bio_lcl.h"
|
||||
# include <openssl/err.h>
|
||||
|
||||
#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
|
||||
#include <nwfileio.h>
|
||||
#endif
|
||||
# if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
|
||||
# include <nwfileio.h>
|
||||
# endif
|
||||
|
||||
#if !defined(OPENSSL_NO_STDIO)
|
||||
# if !defined(OPENSSL_NO_STDIO)
|
||||
|
||||
static int MS_CALLBACK file_write(BIO *h, const char *buf, int num);
|
||||
static int MS_CALLBACK file_read(BIO *h, char *buf, int size);
|
||||
@@ -102,376 +102,364 @@ static int MS_CALLBACK file_gets(BIO *h, char *str, int size);
|
||||
static long MS_CALLBACK file_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int MS_CALLBACK file_new(BIO *h);
|
||||
static int MS_CALLBACK file_free(BIO *data);
|
||||
static BIO_METHOD methods_filep=
|
||||
{
|
||||
BIO_TYPE_FILE,
|
||||
"FILE pointer",
|
||||
file_write,
|
||||
file_read,
|
||||
file_puts,
|
||||
file_gets,
|
||||
file_ctrl,
|
||||
file_new,
|
||||
file_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD methods_filep = {
|
||||
BIO_TYPE_FILE,
|
||||
"FILE pointer",
|
||||
file_write,
|
||||
file_read,
|
||||
file_puts,
|
||||
file_gets,
|
||||
file_ctrl,
|
||||
file_new,
|
||||
file_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO *BIO_new_file(const char *filename, const char *mode)
|
||||
{
|
||||
BIO *ret;
|
||||
FILE *file=NULL;
|
||||
{
|
||||
BIO *ret;
|
||||
FILE *file = NULL;
|
||||
|
||||
#if defined(_WIN32) && defined(CP_UTF8)
|
||||
int sz, len_0 = (int)strlen(filename)+1;
|
||||
DWORD flags;
|
||||
# if defined(_WIN32) && defined(CP_UTF8)
|
||||
int sz, len_0 = (int)strlen(filename) + 1;
|
||||
DWORD flags;
|
||||
|
||||
/*
|
||||
* Basically there are three cases to cover: a) filename is
|
||||
* pure ASCII string; b) actual UTF-8 encoded string and
|
||||
* c) locale-ized string, i.e. one containing 8-bit
|
||||
* characters that are meaningful in current system locale.
|
||||
* If filename is pure ASCII or real UTF-8 encoded string,
|
||||
* MultiByteToWideChar succeeds and _wfopen works. If
|
||||
* filename is locale-ized string, chances are that
|
||||
* MultiByteToWideChar fails reporting
|
||||
* ERROR_NO_UNICODE_TRANSLATION, in which case we fall
|
||||
* back to fopen...
|
||||
*/
|
||||
if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS),
|
||||
filename,len_0,NULL,0))>0 ||
|
||||
(GetLastError()==ERROR_INVALID_FLAGS &&
|
||||
(sz=MultiByteToWideChar(CP_UTF8,(flags=0),
|
||||
filename,len_0,NULL,0))>0)
|
||||
)
|
||||
{
|
||||
WCHAR wmode[8];
|
||||
WCHAR *wfilename = _alloca(sz*sizeof(WCHAR));
|
||||
/*
|
||||
* Basically there are three cases to cover: a) filename is
|
||||
* pure ASCII string; b) actual UTF-8 encoded string and
|
||||
* c) locale-ized string, i.e. one containing 8-bit
|
||||
* characters that are meaningful in current system locale.
|
||||
* If filename is pure ASCII or real UTF-8 encoded string,
|
||||
* MultiByteToWideChar succeeds and _wfopen works. If
|
||||
* filename is locale-ized string, chances are that
|
||||
* MultiByteToWideChar fails reporting
|
||||
* ERROR_NO_UNICODE_TRANSLATION, in which case we fall
|
||||
* back to fopen...
|
||||
*/
|
||||
if ((sz = MultiByteToWideChar(CP_UTF8, (flags = MB_ERR_INVALID_CHARS),
|
||||
filename, len_0, NULL, 0)) > 0 ||
|
||||
(GetLastError() == ERROR_INVALID_FLAGS &&
|
||||
(sz = MultiByteToWideChar(CP_UTF8, (flags = 0),
|
||||
filename, len_0, NULL, 0)) > 0)
|
||||
) {
|
||||
WCHAR wmode[8];
|
||||
WCHAR *wfilename = _alloca(sz * sizeof(WCHAR));
|
||||
|
||||
if (MultiByteToWideChar(CP_UTF8,flags,
|
||||
filename,len_0,wfilename,sz) &&
|
||||
MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1,
|
||||
wmode,sizeof(wmode)/sizeof(wmode[0])) &&
|
||||
(file=_wfopen(wfilename,wmode))==NULL &&
|
||||
(errno==ENOENT || errno==EBADF)
|
||||
) /* UTF-8 decode succeeded, but no file, filename
|
||||
* could still have been locale-ized... */
|
||||
file = fopen(filename,mode);
|
||||
}
|
||||
else if (GetLastError()==ERROR_NO_UNICODE_TRANSLATION)
|
||||
{
|
||||
file = fopen(filename,mode);
|
||||
}
|
||||
#else
|
||||
file=fopen(filename,mode);
|
||||
#endif
|
||||
if (file == NULL)
|
||||
{
|
||||
SYSerr(SYS_F_FOPEN,get_last_sys_error());
|
||||
ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
|
||||
if (errno == ENOENT)
|
||||
BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
|
||||
else
|
||||
BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
|
||||
return(NULL);
|
||||
}
|
||||
if ((ret=BIO_new(BIO_s_file())) == NULL)
|
||||
{
|
||||
fclose(file);
|
||||
return(NULL);
|
||||
}
|
||||
if (MultiByteToWideChar(CP_UTF8, flags,
|
||||
filename, len_0, wfilename, sz) &&
|
||||
MultiByteToWideChar(CP_UTF8, 0, mode, strlen(mode) + 1,
|
||||
wmode, sizeof(wmode) / sizeof(wmode[0])) &&
|
||||
(file = _wfopen(wfilename, wmode)) == NULL &&
|
||||
(errno == ENOENT || errno == EBADF)
|
||||
) {
|
||||
/*
|
||||
* UTF-8 decode succeeded, but no file, filename
|
||||
* could still have been locale-ized...
|
||||
*/
|
||||
file = fopen(filename, mode);
|
||||
}
|
||||
} else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) {
|
||||
file = fopen(filename, mode);
|
||||
}
|
||||
# else
|
||||
file = fopen(filename, mode);
|
||||
# endif
|
||||
if (file == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
|
||||
if (errno == ENOENT)
|
||||
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
|
||||
else
|
||||
BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);
|
||||
return (NULL);
|
||||
}
|
||||
if ((ret = BIO_new(BIO_s_file())) == NULL) {
|
||||
fclose(file);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
BIO_clear_flags(ret,BIO_FLAGS_UPLINK); /* we did fopen -> we disengage UPLINK */
|
||||
BIO_set_fp(ret,file,BIO_CLOSE);
|
||||
return(ret);
|
||||
}
|
||||
BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
|
||||
* UPLINK */
|
||||
BIO_set_fp(ret, file, BIO_CLOSE);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_fp(FILE *stream, int close_flag)
|
||||
{
|
||||
BIO *ret;
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
if ((ret=BIO_new(BIO_s_file())) == NULL)
|
||||
return(NULL);
|
||||
if ((ret = BIO_new(BIO_s_file())) == NULL)
|
||||
return (NULL);
|
||||
|
||||
BIO_set_flags(ret,BIO_FLAGS_UPLINK); /* redundant, left for documentation puposes */
|
||||
BIO_set_fp(ret,stream,close_flag);
|
||||
return(ret);
|
||||
}
|
||||
BIO_set_flags(ret, BIO_FLAGS_UPLINK); /* redundant, left for
|
||||
* documentation puposes */
|
||||
BIO_set_fp(ret, stream, close_flag);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
BIO_METHOD *BIO_s_file(void)
|
||||
{
|
||||
return(&methods_filep);
|
||||
}
|
||||
{
|
||||
return (&methods_filep);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_new(BIO *bi)
|
||||
{
|
||||
bi->init=0;
|
||||
bi->num=0;
|
||||
bi->ptr=NULL;
|
||||
bi->flags=BIO_FLAGS_UPLINK; /* default to UPLINK */
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 0;
|
||||
bi->num = 0;
|
||||
bi->ptr = NULL;
|
||||
bi->flags = BIO_FLAGS_UPLINK; /* default to UPLINK */
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if ((a->init) && (a->ptr != NULL))
|
||||
{
|
||||
if (a->flags&BIO_FLAGS_UPLINK)
|
||||
UP_fclose (a->ptr);
|
||||
else
|
||||
fclose (a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->flags=BIO_FLAGS_UPLINK;
|
||||
}
|
||||
a->init=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->shutdown) {
|
||||
if ((a->init) && (a->ptr != NULL)) {
|
||||
if (a->flags & BIO_FLAGS_UPLINK)
|
||||
UP_fclose(a->ptr);
|
||||
else
|
||||
fclose(a->ptr);
|
||||
a->ptr = NULL;
|
||||
a->flags = BIO_FLAGS_UPLINK;
|
||||
}
|
||||
a->init = 0;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (b->init && (out != NULL))
|
||||
{
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
ret=UP_fread(out,1,(int)outl,b->ptr);
|
||||
else
|
||||
ret=fread(out,1,(int)outl,(FILE *)b->ptr);
|
||||
if(ret == 0 && (b->flags&BIO_FLAGS_UPLINK)?UP_ferror((FILE *)b->ptr):ferror((FILE *)b->ptr))
|
||||
{
|
||||
SYSerr(SYS_F_FREAD,get_last_sys_error());
|
||||
BIOerr(BIO_F_FILE_READ,ERR_R_SYS_LIB);
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
static int MS_CALLBACK file_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (b->init && (out != NULL)) {
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
ret = UP_fread(out, 1, (int)outl, b->ptr);
|
||||
else
|
||||
ret = fread(out, 1, (int)outl, (FILE *)b->ptr);
|
||||
if (ret == 0
|
||||
&& (b->flags & BIO_FLAGS_UPLINK) ? UP_ferror((FILE *)b->ptr) :
|
||||
ferror((FILE *)b->ptr)) {
|
||||
SYSerr(SYS_F_FREAD, get_last_sys_error());
|
||||
BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (b->init && (in != NULL))
|
||||
{
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
ret=UP_fwrite(in,(int)inl,1,b->ptr);
|
||||
else
|
||||
ret=fwrite(in,(int)inl,1,(FILE *)b->ptr);
|
||||
if (ret)
|
||||
ret=inl;
|
||||
/* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
|
||||
/* according to Tim Hudson <tjh@cryptsoft.com>, the commented
|
||||
* out version above can cause 'inl' write calls under
|
||||
* some stupid stdio implementations (VMS) */
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (b->init && (in != NULL)) {
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
ret = UP_fwrite(in, (int)inl, 1, b->ptr);
|
||||
else
|
||||
ret = fwrite(in, (int)inl, 1, (FILE *)b->ptr);
|
||||
if (ret)
|
||||
ret = inl;
|
||||
/* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
|
||||
/*
|
||||
* according to Tim Hudson <tjh@cryptsoft.com>, the commented out
|
||||
* version above can cause 'inl' write calls under some stupid stdio
|
||||
* implementations (VMS)
|
||||
*/
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
FILE *fp=(FILE *)b->ptr;
|
||||
FILE **fpp;
|
||||
char p[4];
|
||||
{
|
||||
long ret = 1;
|
||||
FILE *fp = (FILE *)b->ptr;
|
||||
FILE **fpp;
|
||||
char p[4];
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_C_FILE_SEEK:
|
||||
case BIO_CTRL_RESET:
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
ret=(long)UP_fseek(b->ptr,num,0);
|
||||
else
|
||||
ret=(long)fseek(fp,num,0);
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
ret=(long)UP_feof(fp);
|
||||
else
|
||||
ret=(long)feof(fp);
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
ret=UP_ftell(b->ptr);
|
||||
else
|
||||
ret=ftell(fp);
|
||||
break;
|
||||
case BIO_C_SET_FILE_PTR:
|
||||
file_free(b);
|
||||
b->shutdown=(int)num&BIO_CLOSE;
|
||||
b->ptr=ptr;
|
||||
b->init=1;
|
||||
#if BIO_FLAGS_UPLINK!=0
|
||||
#if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
#define _IOB_ENTRIES 20
|
||||
#endif
|
||||
#if defined(_IOB_ENTRIES)
|
||||
/* Safety net to catch purely internal BIO_set_fp calls */
|
||||
if ((size_t)ptr >= (size_t)stdin &&
|
||||
(size_t)ptr < (size_t)(stdin+_IOB_ENTRIES))
|
||||
BIO_clear_flags(b,BIO_FLAGS_UPLINK);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef UP_fsetmod
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
UP_fsetmod(b->ptr,(char)((num&BIO_FP_TEXT)?'t':'b'));
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if defined(OPENSSL_SYS_WINDOWS)
|
||||
int fd = _fileno((FILE*)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd,_O_TEXT);
|
||||
else
|
||||
_setmode(fd,_O_BINARY);
|
||||
#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
|
||||
int fd = fileno((FILE*)ptr);
|
||||
/* Under CLib there are differences in file modes */
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fd,O_TEXT);
|
||||
else
|
||||
setmode(fd,O_BINARY);
|
||||
#elif defined(OPENSSL_SYS_MSDOS)
|
||||
int fd = fileno((FILE*)ptr);
|
||||
/* Set correct text/binary mode */
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd,_O_TEXT);
|
||||
/* Dangerous to set stdin/stdout to raw (unless redirected) */
|
||||
else
|
||||
{
|
||||
if (fd == STDIN_FILENO || fd == STDOUT_FILENO)
|
||||
{
|
||||
if (isatty(fd) <= 0)
|
||||
_setmode(fd,_O_BINARY);
|
||||
}
|
||||
else
|
||||
_setmode(fd,_O_BINARY);
|
||||
}
|
||||
#elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE*)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fd, O_TEXT);
|
||||
else
|
||||
setmode(fd, O_BINARY);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
file_free(b);
|
||||
b->shutdown=(int)num&BIO_CLOSE;
|
||||
if (num & BIO_FP_APPEND)
|
||||
{
|
||||
if (num & BIO_FP_READ)
|
||||
BUF_strlcpy(p,"a+",sizeof p);
|
||||
else BUF_strlcpy(p,"a",sizeof p);
|
||||
}
|
||||
else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
|
||||
BUF_strlcpy(p,"r+",sizeof p);
|
||||
else if (num & BIO_FP_WRITE)
|
||||
BUF_strlcpy(p,"w",sizeof p);
|
||||
else if (num & BIO_FP_READ)
|
||||
BUF_strlcpy(p,"r",sizeof p);
|
||||
else
|
||||
{
|
||||
BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE);
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p,"b");
|
||||
else
|
||||
strcat(p,"t");
|
||||
#endif
|
||||
#if defined(OPENSSL_SYS_NETWARE)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p,"b");
|
||||
else
|
||||
strcat(p,"t");
|
||||
#endif
|
||||
fp=fopen(ptr,p);
|
||||
if (fp == NULL)
|
||||
{
|
||||
SYSerr(SYS_F_FOPEN,get_last_sys_error());
|
||||
ERR_add_error_data(5,"fopen('",ptr,"','",p,"')");
|
||||
BIOerr(BIO_F_FILE_CTRL,ERR_R_SYS_LIB);
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
b->ptr=fp;
|
||||
b->init=1;
|
||||
BIO_clear_flags(b,BIO_FLAGS_UPLINK); /* we did fopen -> we disengage UPLINK */
|
||||
break;
|
||||
case BIO_C_GET_FILE_PTR:
|
||||
/* the ptr parameter is actually a FILE ** in this case. */
|
||||
if (ptr != NULL)
|
||||
{
|
||||
fpp=(FILE **)ptr;
|
||||
*fpp=(FILE *)b->ptr;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=(long)b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->flags&BIO_FLAGS_UPLINK)
|
||||
UP_fflush(b->ptr);
|
||||
else
|
||||
fflush((FILE *)b->ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret=1;
|
||||
break;
|
||||
switch (cmd) {
|
||||
case BIO_C_FILE_SEEK:
|
||||
case BIO_CTRL_RESET:
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
ret = (long)UP_fseek(b->ptr, num, 0);
|
||||
else
|
||||
ret = (long)fseek(fp, num, 0);
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
ret = (long)UP_feof(fp);
|
||||
else
|
||||
ret = (long)feof(fp);
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
ret = UP_ftell(b->ptr);
|
||||
else
|
||||
ret = ftell(fp);
|
||||
break;
|
||||
case BIO_C_SET_FILE_PTR:
|
||||
file_free(b);
|
||||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
b->ptr = ptr;
|
||||
b->init = 1;
|
||||
# if BIO_FLAGS_UPLINK!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
# if defined(_IOB_ENTRIES)
|
||||
/* Safety net to catch purely internal BIO_set_fp calls */
|
||||
if ((size_t)ptr >= (size_t)stdin &&
|
||||
(size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK);
|
||||
# endif
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));
|
||||
else
|
||||
# endif
|
||||
{
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
int fd = _fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd, _O_TEXT);
|
||||
else
|
||||
_setmode(fd, _O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
/* Under CLib there are differences in file modes */
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fd, O_TEXT);
|
||||
else
|
||||
setmode(fd, O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
/* Set correct text/binary mode */
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd, _O_TEXT);
|
||||
/* Dangerous to set stdin/stdout to raw (unless redirected) */
|
||||
else {
|
||||
if (fd == STDIN_FILENO || fd == STDOUT_FILENO) {
|
||||
if (isatty(fd) <= 0)
|
||||
_setmode(fd, _O_BINARY);
|
||||
} else
|
||||
_setmode(fd, _O_BINARY);
|
||||
}
|
||||
# elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fd, O_TEXT);
|
||||
else
|
||||
setmode(fd, O_BINARY);
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
file_free(b);
|
||||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
if (num & BIO_FP_APPEND) {
|
||||
if (num & BIO_FP_READ)
|
||||
BUF_strlcpy(p, "a+", sizeof p);
|
||||
else
|
||||
BUF_strlcpy(p, "a", sizeof p);
|
||||
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
|
||||
BUF_strlcpy(p, "r+", sizeof p);
|
||||
else if (num & BIO_FP_WRITE)
|
||||
BUF_strlcpy(p, "w", sizeof p);
|
||||
else if (num & BIO_FP_READ)
|
||||
BUF_strlcpy(p, "r", sizeof p);
|
||||
else {
|
||||
BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p, "b");
|
||||
else
|
||||
strcat(p, "t");
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_NETWARE)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p, "b");
|
||||
else
|
||||
strcat(p, "t");
|
||||
# endif
|
||||
fp = fopen(ptr, p);
|
||||
if (fp == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
|
||||
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
b->ptr = fp;
|
||||
b->init = 1;
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
|
||||
* UPLINK */
|
||||
break;
|
||||
case BIO_C_GET_FILE_PTR:
|
||||
/* the ptr parameter is actually a FILE ** in this case. */
|
||||
if (ptr != NULL) {
|
||||
fpp = (FILE **)ptr;
|
||||
*fpp = (FILE *)b->ptr;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = (long)b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
UP_fflush(b->ptr);
|
||||
else
|
||||
fflush((FILE *)b->ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret = 1;
|
||||
break;
|
||||
|
||||
case BIO_CTRL_WPENDING:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
case BIO_CTRL_WPENDING:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
buf[0]='\0';
|
||||
if (bp->flags&BIO_FLAGS_UPLINK)
|
||||
{
|
||||
if (!UP_fgets(buf,size,bp->ptr))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fgets(buf,size,(FILE *)bp->ptr))
|
||||
goto err;
|
||||
}
|
||||
if (buf[0] != '\0')
|
||||
ret=strlen(buf);
|
||||
err:
|
||||
return(ret);
|
||||
}
|
||||
buf[0] = '\0';
|
||||
if (bp->flags & BIO_FLAGS_UPLINK) {
|
||||
if (!UP_fgets(buf, size, bp->ptr))
|
||||
goto err;
|
||||
} else {
|
||||
if (!fgets(buf, size, (FILE *)bp->ptr))
|
||||
goto err;
|
||||
}
|
||||
if (buf[0] != '\0')
|
||||
ret = strlen(buf);
|
||||
err:
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
{
|
||||
int n, ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=file_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#endif /* OPENSSL_NO_STDIO */
|
||||
|
||||
#endif /* HEADER_BSS_FILE_C */
|
||||
n = strlen(str);
|
||||
ret = file_write(bp, str, n);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
# endif /* OPENSSL_NO_STDIO */
|
||||
|
||||
#endif /* HEADER_BSS_FILE_C */
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
@@ -54,14 +54,13 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Why BIO_s_log?
|
||||
|
||||
BIO_s_log is useful for system daemons (or services under NT).
|
||||
It is one-way BIO, it sends all stuff to syslogd (on system that
|
||||
commonly use that), or event log (on NT), or OPCOM (on OpenVMS).
|
||||
|
||||
*/
|
||||
|
||||
* Why BIO_s_log?
|
||||
*
|
||||
* BIO_s_log is useful for system daemons (or services under NT). It is
|
||||
* one-way BIO, it sends all stuff to syslogd (on system that commonly use
|
||||
* that), or event log (on NT), or OPCOM (on OpenVMS).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
@@ -71,16 +70,26 @@
|
||||
#if defined(OPENSSL_SYS_WINCE)
|
||||
#elif defined(OPENSSL_SYS_WIN32)
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
# include <opcdef.h>
|
||||
# include <descrip.h>
|
||||
# include <lib$routines.h>
|
||||
# include <starlet.h>
|
||||
# include <opcdef.h>
|
||||
# include <descrip.h>
|
||||
# include <lib$routines.h>
|
||||
# include <starlet.h>
|
||||
/* Some compiler options may mask the declaration of "_malloc32". */
|
||||
# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
|
||||
# if __INITIAL_POINTER_SIZE == 64
|
||||
# pragma pointer_size save
|
||||
# pragma pointer_size 32
|
||||
void *_malloc32(__size_t);
|
||||
# pragma pointer_size restore
|
||||
# endif /* __INITIAL_POINTER_SIZE == 64 */
|
||||
# endif /* __INITIAL_POINTER_SIZE && defined
|
||||
* _ANSI_C_SOURCE */
|
||||
#elif defined(__ultrix)
|
||||
# include <sys/syslog.h>
|
||||
# include <sys/syslog.h>
|
||||
#elif defined(OPENSSL_SYS_NETWARE)
|
||||
# define NO_SYSLOG
|
||||
# define NO_SYSLOG
|
||||
#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
|
||||
# include <syslog.h>
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/buffer.h>
|
||||
@@ -88,286 +97,357 @@
|
||||
|
||||
#ifndef NO_SYSLOG
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN32)
|
||||
#define LOG_EMERG 0
|
||||
#define LOG_ALERT 1
|
||||
#define LOG_CRIT 2
|
||||
#define LOG_ERR 3
|
||||
#define LOG_WARNING 4
|
||||
#define LOG_NOTICE 5
|
||||
#define LOG_INFO 6
|
||||
#define LOG_DEBUG 7
|
||||
# if defined(OPENSSL_SYS_WIN32)
|
||||
# define LOG_EMERG 0
|
||||
# define LOG_ALERT 1
|
||||
# define LOG_CRIT 2
|
||||
# define LOG_ERR 3
|
||||
# define LOG_WARNING 4
|
||||
# define LOG_NOTICE 5
|
||||
# define LOG_INFO 6
|
||||
# define LOG_DEBUG 7
|
||||
|
||||
#define LOG_DAEMON (3<<3)
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
# define LOG_DAEMON (3<<3)
|
||||
# elif defined(OPENSSL_SYS_VMS)
|
||||
/* On VMS, we don't really care about these, but we need them to compile */
|
||||
#define LOG_EMERG 0
|
||||
#define LOG_ALERT 1
|
||||
#define LOG_CRIT 2
|
||||
#define LOG_ERR 3
|
||||
#define LOG_WARNING 4
|
||||
#define LOG_NOTICE 5
|
||||
#define LOG_INFO 6
|
||||
#define LOG_DEBUG 7
|
||||
# define LOG_EMERG 0
|
||||
# define LOG_ALERT 1
|
||||
# define LOG_CRIT 2
|
||||
# define LOG_ERR 3
|
||||
# define LOG_WARNING 4
|
||||
# define LOG_NOTICE 5
|
||||
# define LOG_INFO 6
|
||||
# define LOG_DEBUG 7
|
||||
|
||||
#define LOG_DAEMON OPC$M_NM_NTWORK
|
||||
#endif
|
||||
# define LOG_DAEMON OPC$M_NM_NTWORK
|
||||
# endif
|
||||
|
||||
static int MS_CALLBACK slg_write(BIO *h, const char *buf, int num);
|
||||
static int MS_CALLBACK slg_puts(BIO *h, const char *str);
|
||||
static long MS_CALLBACK slg_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int MS_CALLBACK slg_new(BIO *h);
|
||||
static int MS_CALLBACK slg_free(BIO *data);
|
||||
static void xopenlog(BIO* bp, char* name, int level);
|
||||
static void xsyslog(BIO* bp, int priority, const char* string);
|
||||
static void xcloselog(BIO* bp);
|
||||
static void xopenlog(BIO *bp, char *name, int level);
|
||||
static void xsyslog(BIO *bp, int priority, const char *string);
|
||||
static void xcloselog(BIO *bp);
|
||||
|
||||
static BIO_METHOD methods_slg=
|
||||
{
|
||||
BIO_TYPE_MEM,"syslog",
|
||||
slg_write,
|
||||
NULL,
|
||||
slg_puts,
|
||||
NULL,
|
||||
slg_ctrl,
|
||||
slg_new,
|
||||
slg_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD methods_slg = {
|
||||
BIO_TYPE_MEM, "syslog",
|
||||
slg_write,
|
||||
NULL,
|
||||
slg_puts,
|
||||
NULL,
|
||||
slg_ctrl,
|
||||
slg_new,
|
||||
slg_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_log(void)
|
||||
{
|
||||
return(&methods_slg);
|
||||
}
|
||||
{
|
||||
return (&methods_slg);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_new(BIO *bi)
|
||||
{
|
||||
bi->init=1;
|
||||
bi->num=0;
|
||||
bi->ptr=NULL;
|
||||
xopenlog(bi, "application", LOG_DAEMON);
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 1;
|
||||
bi->num = 0;
|
||||
bi->ptr = NULL;
|
||||
xopenlog(bi, "application", LOG_DAEMON);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
xcloselog(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
xcloselog(a);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret= inl;
|
||||
char* buf;
|
||||
char* pp;
|
||||
int priority, i;
|
||||
static const struct
|
||||
{
|
||||
int strl;
|
||||
char str[10];
|
||||
int log_level;
|
||||
}
|
||||
mapping[] =
|
||||
{
|
||||
{ 6, "PANIC ", LOG_EMERG },
|
||||
{ 6, "EMERG ", LOG_EMERG },
|
||||
{ 4, "EMR ", LOG_EMERG },
|
||||
{ 6, "ALERT ", LOG_ALERT },
|
||||
{ 4, "ALR ", LOG_ALERT },
|
||||
{ 5, "CRIT ", LOG_CRIT },
|
||||
{ 4, "CRI ", LOG_CRIT },
|
||||
{ 6, "ERROR ", LOG_ERR },
|
||||
{ 4, "ERR ", LOG_ERR },
|
||||
{ 8, "WARNING ", LOG_WARNING },
|
||||
{ 5, "WARN ", LOG_WARNING },
|
||||
{ 4, "WAR ", LOG_WARNING },
|
||||
{ 7, "NOTICE ", LOG_NOTICE },
|
||||
{ 5, "NOTE ", LOG_NOTICE },
|
||||
{ 4, "NOT ", LOG_NOTICE },
|
||||
{ 5, "INFO ", LOG_INFO },
|
||||
{ 4, "INF ", LOG_INFO },
|
||||
{ 6, "DEBUG ", LOG_DEBUG },
|
||||
{ 4, "DBG ", LOG_DEBUG },
|
||||
{ 0, "", LOG_ERR } /* The default */
|
||||
};
|
||||
{
|
||||
int ret = inl;
|
||||
char *buf;
|
||||
char *pp;
|
||||
int priority, i;
|
||||
static const struct {
|
||||
int strl;
|
||||
char str[10];
|
||||
int log_level;
|
||||
} mapping[] = {
|
||||
{
|
||||
6, "PANIC ", LOG_EMERG
|
||||
},
|
||||
{
|
||||
6, "EMERG ", LOG_EMERG
|
||||
},
|
||||
{
|
||||
4, "EMR ", LOG_EMERG
|
||||
},
|
||||
{
|
||||
6, "ALERT ", LOG_ALERT
|
||||
},
|
||||
{
|
||||
4, "ALR ", LOG_ALERT
|
||||
},
|
||||
{
|
||||
5, "CRIT ", LOG_CRIT
|
||||
},
|
||||
{
|
||||
4, "CRI ", LOG_CRIT
|
||||
},
|
||||
{
|
||||
6, "ERROR ", LOG_ERR
|
||||
},
|
||||
{
|
||||
4, "ERR ", LOG_ERR
|
||||
},
|
||||
{
|
||||
8, "WARNING ", LOG_WARNING
|
||||
},
|
||||
{
|
||||
5, "WARN ", LOG_WARNING
|
||||
},
|
||||
{
|
||||
4, "WAR ", LOG_WARNING
|
||||
},
|
||||
{
|
||||
7, "NOTICE ", LOG_NOTICE
|
||||
},
|
||||
{
|
||||
5, "NOTE ", LOG_NOTICE
|
||||
},
|
||||
{
|
||||
4, "NOT ", LOG_NOTICE
|
||||
},
|
||||
{
|
||||
5, "INFO ", LOG_INFO
|
||||
},
|
||||
{
|
||||
4, "INF ", LOG_INFO
|
||||
},
|
||||
{
|
||||
6, "DEBUG ", LOG_DEBUG
|
||||
},
|
||||
{
|
||||
4, "DBG ", LOG_DEBUG
|
||||
},
|
||||
{
|
||||
0, "", LOG_ERR
|
||||
}
|
||||
/* The default */
|
||||
};
|
||||
|
||||
if((buf= (char *)OPENSSL_malloc(inl+ 1)) == NULL){
|
||||
return(0);
|
||||
}
|
||||
strncpy(buf, in, inl);
|
||||
buf[inl]= '\0';
|
||||
if ((buf = (char *)OPENSSL_malloc(inl + 1)) == NULL) {
|
||||
return (0);
|
||||
}
|
||||
strncpy(buf, in, inl);
|
||||
buf[inl] = '\0';
|
||||
|
||||
i = 0;
|
||||
while(strncmp(buf, mapping[i].str, mapping[i].strl) != 0) i++;
|
||||
priority = mapping[i].log_level;
|
||||
pp = buf + mapping[i].strl;
|
||||
i = 0;
|
||||
while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0)
|
||||
i++;
|
||||
priority = mapping[i].log_level;
|
||||
pp = buf + mapping[i].strl;
|
||||
|
||||
xsyslog(b, priority, pp);
|
||||
xsyslog(b, priority, pp);
|
||||
|
||||
OPENSSL_free(buf);
|
||||
return(ret);
|
||||
}
|
||||
OPENSSL_free(buf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long MS_CALLBACK slg_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_SET:
|
||||
xcloselog(b);
|
||||
xopenlog(b, ptr, num);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
{
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_SET:
|
||||
xcloselog(b);
|
||||
xopenlog(b, ptr, num);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=slg_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN32)
|
||||
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
{
|
||||
if (GetVersion() < 0x80000000)
|
||||
bp->ptr = RegisterEventSourceA(NULL,name);
|
||||
else
|
||||
bp->ptr = NULL;
|
||||
int n, ret;
|
||||
|
||||
n = strlen(str);
|
||||
ret = slg_write(bp, str, n);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
# if defined(OPENSSL_SYS_WIN32)
|
||||
|
||||
static void xopenlog(BIO *bp, char *name, int level)
|
||||
{
|
||||
if (check_winnt())
|
||||
bp->ptr = RegisterEventSourceA(NULL, name);
|
||||
else
|
||||
bp->ptr = NULL;
|
||||
}
|
||||
|
||||
static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
{
|
||||
LPCSTR lpszStrings[2];
|
||||
WORD evtype= EVENTLOG_ERROR_TYPE;
|
||||
char pidbuf[DECIMAL_SIZE(DWORD)+4];
|
||||
LPCSTR lpszStrings[2];
|
||||
WORD evtype = EVENTLOG_ERROR_TYPE;
|
||||
char pidbuf[DECIMAL_SIZE(DWORD) + 4];
|
||||
|
||||
if (bp->ptr == NULL)
|
||||
return;
|
||||
if (bp->ptr == NULL)
|
||||
return;
|
||||
|
||||
switch (priority)
|
||||
{
|
||||
case LOG_EMERG:
|
||||
case LOG_ALERT:
|
||||
case LOG_CRIT:
|
||||
case LOG_ERR:
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
evtype = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
case LOG_INFO:
|
||||
case LOG_DEBUG:
|
||||
evtype = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
default: /* Should never happen, but set it
|
||||
as error anyway. */
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
switch (priority) {
|
||||
case LOG_EMERG:
|
||||
case LOG_ALERT:
|
||||
case LOG_CRIT:
|
||||
case LOG_ERR:
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
evtype = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
case LOG_INFO:
|
||||
case LOG_DEBUG:
|
||||
evtype = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Should never happen, but set it
|
||||
* as error anyway.
|
||||
*/
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
|
||||
lpszStrings[0] = pidbuf;
|
||||
lpszStrings[1] = string;
|
||||
sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
|
||||
lpszStrings[0] = pidbuf;
|
||||
lpszStrings[1] = string;
|
||||
|
||||
ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
|
||||
lpszStrings, NULL);
|
||||
ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0, lpszStrings, NULL);
|
||||
}
|
||||
|
||||
static void xcloselog(BIO* bp)
|
||||
|
||||
static void xcloselog(BIO *bp)
|
||||
{
|
||||
if(bp->ptr)
|
||||
DeregisterEventSource((HANDLE)(bp->ptr));
|
||||
bp->ptr= NULL;
|
||||
if (bp->ptr)
|
||||
DeregisterEventSource((HANDLE) (bp->ptr));
|
||||
bp->ptr = NULL;
|
||||
}
|
||||
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
# elif defined(OPENSSL_SYS_VMS)
|
||||
|
||||
static int VMS_OPC_target = LOG_DAEMON;
|
||||
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
static void xopenlog(BIO *bp, char *name, int level)
|
||||
{
|
||||
VMS_OPC_target = level;
|
||||
VMS_OPC_target = level;
|
||||
}
|
||||
|
||||
static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
{
|
||||
struct dsc$descriptor_s opc_dsc;
|
||||
struct opcdef *opcdef_p;
|
||||
char buf[10240];
|
||||
unsigned int len;
|
||||
struct dsc$descriptor_s buf_dsc;
|
||||
$DESCRIPTOR(fao_cmd, "!AZ: !AZ");
|
||||
char *priority_tag;
|
||||
struct dsc$descriptor_s opc_dsc;
|
||||
|
||||
switch (priority)
|
||||
{
|
||||
case LOG_EMERG: priority_tag = "Emergency"; break;
|
||||
case LOG_ALERT: priority_tag = "Alert"; break;
|
||||
case LOG_CRIT: priority_tag = "Critical"; break;
|
||||
case LOG_ERR: priority_tag = "Error"; break;
|
||||
case LOG_WARNING: priority_tag = "Warning"; break;
|
||||
case LOG_NOTICE: priority_tag = "Notice"; break;
|
||||
case LOG_INFO: priority_tag = "Info"; break;
|
||||
case LOG_DEBUG: priority_tag = "DEBUG"; break;
|
||||
}
|
||||
/* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */
|
||||
# if __INITIAL_POINTER_SIZE == 64
|
||||
# pragma pointer_size save
|
||||
# pragma pointer_size 32
|
||||
# define OPCDEF_TYPE __char_ptr32
|
||||
# define OPCDEF_MALLOC _malloc32
|
||||
# else /* __INITIAL_POINTER_SIZE == 64 */
|
||||
# define OPCDEF_TYPE char *
|
||||
# define OPCDEF_MALLOC OPENSSL_malloc
|
||||
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
||||
|
||||
buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
buf_dsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
buf_dsc.dsc$a_pointer = buf;
|
||||
buf_dsc.dsc$w_length = sizeof(buf) - 1;
|
||||
struct opcdef *opcdef_p;
|
||||
|
||||
lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
|
||||
# if __INITIAL_POINTER_SIZE == 64
|
||||
# pragma pointer_size restore
|
||||
# endif /* __INITIAL_POINTER_SIZE == 64 */
|
||||
|
||||
/* we know there's an 8 byte header. That's documented */
|
||||
opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len);
|
||||
opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
|
||||
memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
|
||||
opcdef_p->opc$l_ms_rqstid = 0;
|
||||
memcpy(&opcdef_p->opc$l_ms_text, buf, len);
|
||||
char buf[10240];
|
||||
unsigned int len;
|
||||
struct dsc$descriptor_s buf_dsc;
|
||||
$DESCRIPTOR(fao_cmd, "!AZ: !AZ");
|
||||
char *priority_tag;
|
||||
|
||||
opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
opc_dsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
opc_dsc.dsc$a_pointer = (char *)opcdef_p;
|
||||
opc_dsc.dsc$w_length = len + 8;
|
||||
switch (priority) {
|
||||
case LOG_EMERG:
|
||||
priority_tag = "Emergency";
|
||||
break;
|
||||
case LOG_ALERT:
|
||||
priority_tag = "Alert";
|
||||
break;
|
||||
case LOG_CRIT:
|
||||
priority_tag = "Critical";
|
||||
break;
|
||||
case LOG_ERR:
|
||||
priority_tag = "Error";
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
priority_tag = "Warning";
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
priority_tag = "Notice";
|
||||
break;
|
||||
case LOG_INFO:
|
||||
priority_tag = "Info";
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
priority_tag = "DEBUG";
|
||||
break;
|
||||
}
|
||||
|
||||
sys$sndopr(opc_dsc, 0);
|
||||
buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
buf_dsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
buf_dsc.dsc$a_pointer = buf;
|
||||
buf_dsc.dsc$w_length = sizeof(buf) - 1;
|
||||
|
||||
OPENSSL_free(opcdef_p);
|
||||
lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
|
||||
|
||||
/* We know there's an 8-byte header. That's documented. */
|
||||
opcdef_p = OPCDEF_MALLOC(8 + len);
|
||||
opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
|
||||
memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
|
||||
opcdef_p->opc$l_ms_rqstid = 0;
|
||||
memcpy(&opcdef_p->opc$l_ms_text, buf, len);
|
||||
|
||||
opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
opc_dsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p;
|
||||
opc_dsc.dsc$w_length = len + 8;
|
||||
|
||||
sys$sndopr(opc_dsc, 0);
|
||||
|
||||
OPENSSL_free(opcdef_p);
|
||||
}
|
||||
|
||||
static void xcloselog(BIO* bp)
|
||||
static void xcloselog(BIO *bp)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* Unix/Watt32 */
|
||||
# else /* Unix/Watt32 */
|
||||
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
static void xopenlog(BIO *bp, char *name, int level)
|
||||
{
|
||||
#ifdef WATT32 /* djgpp/DOS */
|
||||
openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level);
|
||||
#else
|
||||
openlog(name, LOG_PID|LOG_CONS, level);
|
||||
#endif
|
||||
# ifdef WATT32 /* djgpp/DOS */
|
||||
openlog(name, LOG_PID | LOG_CONS | LOG_NDELAY, level);
|
||||
# else
|
||||
openlog(name, LOG_PID | LOG_CONS, level);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
{
|
||||
syslog(priority, "%s", string);
|
||||
syslog(priority, "%s", string);
|
||||
}
|
||||
|
||||
static void xcloselog(BIO* bp)
|
||||
static void xcloselog(BIO *bp)
|
||||
{
|
||||
closelog();
|
||||
closelog();
|
||||
}
|
||||
|
||||
#endif /* Unix */
|
||||
# endif /* Unix */
|
||||
|
||||
#endif /* NO_SYSLOG */
|
||||
#endif /* NO_SYSLOG */
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -68,252 +68,244 @@ static int mem_gets(BIO *h, char *str, int size);
|
||||
static long mem_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int mem_new(BIO *h);
|
||||
static int mem_free(BIO *data);
|
||||
static BIO_METHOD mem_method=
|
||||
{
|
||||
BIO_TYPE_MEM,
|
||||
"memory buffer",
|
||||
mem_write,
|
||||
mem_read,
|
||||
mem_puts,
|
||||
mem_gets,
|
||||
mem_ctrl,
|
||||
mem_new,
|
||||
mem_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD mem_method = {
|
||||
BIO_TYPE_MEM,
|
||||
"memory buffer",
|
||||
mem_write,
|
||||
mem_read,
|
||||
mem_puts,
|
||||
mem_gets,
|
||||
mem_ctrl,
|
||||
mem_new,
|
||||
mem_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* bio->num is used to hold the value to return on 'empty', if it is
|
||||
* 0, should_retry is not set */
|
||||
/*
|
||||
* bio->num is used to hold the value to return on 'empty', if it is 0,
|
||||
* should_retry is not set
|
||||
*/
|
||||
|
||||
BIO_METHOD *BIO_s_mem(void)
|
||||
{
|
||||
return(&mem_method);
|
||||
}
|
||||
{
|
||||
return (&mem_method);
|
||||
}
|
||||
|
||||
BIO *BIO_new_mem_buf(void *buf, int len)
|
||||
{
|
||||
BIO *ret;
|
||||
BUF_MEM *b;
|
||||
size_t sz;
|
||||
BIO *ret;
|
||||
BUF_MEM *b;
|
||||
size_t sz;
|
||||
|
||||
if (!buf) {
|
||||
BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
sz = (len<0) ? strlen(buf) : (size_t)len;
|
||||
if(!(ret = BIO_new(BIO_s_mem())) ) return NULL;
|
||||
b = (BUF_MEM *)ret->ptr;
|
||||
b->data = buf;
|
||||
b->length = sz;
|
||||
b->max = sz;
|
||||
ret->flags |= BIO_FLAGS_MEM_RDONLY;
|
||||
/* Since this is static data retrying wont help */
|
||||
ret->num = 0;
|
||||
return ret;
|
||||
if (!buf) {
|
||||
BIOerr(BIO_F_BIO_NEW_MEM_BUF, BIO_R_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
sz = (len < 0) ? strlen(buf) : (size_t)len;
|
||||
if (!(ret = BIO_new(BIO_s_mem())))
|
||||
return NULL;
|
||||
b = (BUF_MEM *)ret->ptr;
|
||||
b->data = buf;
|
||||
b->length = sz;
|
||||
b->max = sz;
|
||||
ret->flags |= BIO_FLAGS_MEM_RDONLY;
|
||||
/* Since this is static data retrying wont help */
|
||||
ret->num = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mem_new(BIO *bi)
|
||||
{
|
||||
BUF_MEM *b;
|
||||
{
|
||||
BUF_MEM *b;
|
||||
|
||||
if ((b=BUF_MEM_new()) == NULL)
|
||||
return(0);
|
||||
bi->shutdown=1;
|
||||
bi->init=1;
|
||||
bi->num= -1;
|
||||
bi->ptr=(char *)b;
|
||||
return(1);
|
||||
}
|
||||
if ((b = BUF_MEM_new()) == NULL)
|
||||
return (0);
|
||||
bi->shutdown = 1;
|
||||
bi->init = 1;
|
||||
bi->num = -1;
|
||||
bi->ptr = (char *)b;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int mem_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if ((a->init) && (a->ptr != NULL))
|
||||
{
|
||||
BUF_MEM *b;
|
||||
b = (BUF_MEM *)a->ptr;
|
||||
if(a->flags & BIO_FLAGS_MEM_RDONLY) b->data = NULL;
|
||||
BUF_MEM_free(b);
|
||||
a->ptr=NULL;
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int mem_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret= -1;
|
||||
BUF_MEM *bm;
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->shutdown) {
|
||||
if ((a->init) && (a->ptr != NULL)) {
|
||||
BUF_MEM *b;
|
||||
b = (BUF_MEM *)a->ptr;
|
||||
if (a->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
b->data = NULL;
|
||||
BUF_MEM_free(b);
|
||||
a->ptr = NULL;
|
||||
}
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
bm=(BUF_MEM *)b->ptr;
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=(outl >=0 && (size_t)outl > bm->length)?(int)bm->length:outl;
|
||||
if ((out != NULL) && (ret > 0)) {
|
||||
memcpy(out,bm->data,ret);
|
||||
bm->length-=ret;
|
||||
if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret;
|
||||
else {
|
||||
memmove(&(bm->data[0]),&(bm->data[ret]),bm->length);
|
||||
}
|
||||
} else if (bm->length == 0)
|
||||
{
|
||||
ret = b->num;
|
||||
if (ret != 0)
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
static int mem_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret = -1;
|
||||
BUF_MEM *bm;
|
||||
|
||||
bm = (BUF_MEM *)b->ptr;
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = (outl >= 0 && (size_t)outl > bm->length) ? (int)bm->length : outl;
|
||||
if ((out != NULL) && (ret > 0)) {
|
||||
memcpy(out, bm->data, ret);
|
||||
bm->length -= ret;
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
bm->data += ret;
|
||||
else {
|
||||
memmove(&(bm->data[0]), &(bm->data[ret]), bm->length);
|
||||
}
|
||||
} else if (bm->length == 0) {
|
||||
ret = b->num;
|
||||
if (ret != 0)
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int mem_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret= -1;
|
||||
int blen;
|
||||
BUF_MEM *bm;
|
||||
{
|
||||
int ret = -1;
|
||||
int blen;
|
||||
BUF_MEM *bm;
|
||||
|
||||
bm=(BUF_MEM *)b->ptr;
|
||||
if (in == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_MEM_WRITE,BIO_R_NULL_PARAMETER);
|
||||
goto end;
|
||||
}
|
||||
bm = (BUF_MEM *)b->ptr;
|
||||
if (in == NULL) {
|
||||
BIOerr(BIO_F_MEM_WRITE, BIO_R_NULL_PARAMETER);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(b->flags & BIO_FLAGS_MEM_RDONLY) {
|
||||
BIOerr(BIO_F_MEM_WRITE,BIO_R_WRITE_TO_READ_ONLY_BIO);
|
||||
goto end;
|
||||
}
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY) {
|
||||
BIOerr(BIO_F_MEM_WRITE, BIO_R_WRITE_TO_READ_ONLY_BIO);
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
blen=bm->length;
|
||||
if (BUF_MEM_grow_clean(bm,blen+inl) != (blen+inl))
|
||||
goto end;
|
||||
memcpy(&(bm->data[blen]),in,inl);
|
||||
ret=inl;
|
||||
end:
|
||||
return(ret);
|
||||
}
|
||||
BIO_clear_retry_flags(b);
|
||||
blen = bm->length;
|
||||
if (BUF_MEM_grow_clean(bm, blen + inl) != (blen + inl))
|
||||
goto end;
|
||||
memcpy(&(bm->data[blen]), in, inl);
|
||||
ret = inl;
|
||||
end:
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
char **pptr;
|
||||
{
|
||||
long ret = 1;
|
||||
char **pptr;
|
||||
|
||||
BUF_MEM *bm=(BUF_MEM *)b->ptr;
|
||||
BUF_MEM *bm = (BUF_MEM *)b->ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
if (bm->data != NULL)
|
||||
{
|
||||
/* For read only case reset to the start again */
|
||||
if(b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
{
|
||||
bm->data -= bm->max - bm->length;
|
||||
bm->length = bm->max;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(bm->data,0,bm->max);
|
||||
bm->length=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret=(long)(bm->length == 0);
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM_EOF_RETURN:
|
||||
b->num=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)bm->length;
|
||||
if (ptr != NULL)
|
||||
{
|
||||
pptr=(char **)ptr;
|
||||
*pptr=(char *)&(bm->data[0]);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM:
|
||||
mem_free(b);
|
||||
b->shutdown=(int)num;
|
||||
b->ptr=ptr;
|
||||
break;
|
||||
case BIO_C_GET_BUF_MEM_PTR:
|
||||
if (ptr != NULL)
|
||||
{
|
||||
pptr=(char **)ptr;
|
||||
*pptr=(char *)bm;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=(long)b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
if (bm->data != NULL) {
|
||||
/* For read only case reset to the start again */
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY) {
|
||||
bm->data -= bm->max - bm->length;
|
||||
bm->length = bm->max;
|
||||
} else {
|
||||
memset(bm->data, 0, bm->max);
|
||||
bm->length = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret = (long)(bm->length == 0);
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM_EOF_RETURN:
|
||||
b->num = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret = (long)bm->length;
|
||||
if (ptr != NULL) {
|
||||
pptr = (char **)ptr;
|
||||
*pptr = (char *)&(bm->data[0]);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM:
|
||||
mem_free(b);
|
||||
b->shutdown = (int)num;
|
||||
b->ptr = ptr;
|
||||
break;
|
||||
case BIO_C_GET_BUF_MEM_PTR:
|
||||
if (ptr != NULL) {
|
||||
pptr = (char **)ptr;
|
||||
*pptr = (char *)bm;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = (long)b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown = (int)num;
|
||||
break;
|
||||
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=0L;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
ret=(long)bm->length;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret=1;
|
||||
break;
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret = 0L;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
ret = (long)bm->length;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int mem_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
int i,j;
|
||||
int ret= -1;
|
||||
char *p;
|
||||
BUF_MEM *bm=(BUF_MEM *)bp->ptr;
|
||||
{
|
||||
int i, j;
|
||||
int ret = -1;
|
||||
char *p;
|
||||
BUF_MEM *bm = (BUF_MEM *)bp->ptr;
|
||||
|
||||
BIO_clear_retry_flags(bp);
|
||||
j=bm->length;
|
||||
if ((size-1) < j) j=size-1;
|
||||
if (j <= 0)
|
||||
{
|
||||
*buf='\0';
|
||||
return 0;
|
||||
}
|
||||
p=bm->data;
|
||||
for (i=0; i<j; i++)
|
||||
{
|
||||
if (p[i] == '\n')
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BIO_clear_retry_flags(bp);
|
||||
j = bm->length;
|
||||
if ((size - 1) < j)
|
||||
j = size - 1;
|
||||
if (j <= 0) {
|
||||
*buf = '\0';
|
||||
return 0;
|
||||
}
|
||||
p = bm->data;
|
||||
for (i = 0; i < j; i++) {
|
||||
if (p[i] == '\n') {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* i is now the max num of bytes to copy, either j or up to
|
||||
* and including the first newline
|
||||
*/
|
||||
/*
|
||||
* i is now the max num of bytes to copy, either j or up to
|
||||
* and including the first newline
|
||||
*/
|
||||
|
||||
i=mem_read(bp,buf,i);
|
||||
if (i > 0) buf[i]='\0';
|
||||
ret=i;
|
||||
return(ret);
|
||||
}
|
||||
i = mem_read(bp, buf, i);
|
||||
if (i > 0)
|
||||
buf[i] = '\0';
|
||||
ret = i;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int mem_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=mem_write(bp,str,n);
|
||||
/* memory semantics is that it will always work */
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
int n, ret;
|
||||
|
||||
n = strlen(str);
|
||||
ret = mem_write(bp, str, n);
|
||||
/* memory semantics is that it will always work */
|
||||
return (ret);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -68,83 +68,82 @@ static int null_gets(BIO *h, char *str, int size);
|
||||
static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int null_new(BIO *h);
|
||||
static int null_free(BIO *data);
|
||||
static BIO_METHOD null_method=
|
||||
{
|
||||
BIO_TYPE_NULL,
|
||||
"NULL",
|
||||
null_write,
|
||||
null_read,
|
||||
null_puts,
|
||||
null_gets,
|
||||
null_ctrl,
|
||||
null_new,
|
||||
null_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD null_method = {
|
||||
BIO_TYPE_NULL,
|
||||
"NULL",
|
||||
null_write,
|
||||
null_read,
|
||||
null_puts,
|
||||
null_gets,
|
||||
null_ctrl,
|
||||
null_new,
|
||||
null_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_null(void)
|
||||
{
|
||||
return(&null_method);
|
||||
}
|
||||
{
|
||||
return (&null_method);
|
||||
}
|
||||
|
||||
static int null_new(BIO *bi)
|
||||
{
|
||||
bi->init=1;
|
||||
bi->num=0;
|
||||
bi->ptr=(NULL);
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 1;
|
||||
bi->num = 0;
|
||||
bi->ptr = (NULL);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int null_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int null_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int null_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
return(inl);
|
||||
}
|
||||
{
|
||||
return (inl);
|
||||
}
|
||||
|
||||
static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
case BIO_CTRL_EOF:
|
||||
case BIO_CTRL_SET:
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
case BIO_CTRL_FLUSH:
|
||||
case BIO_CTRL_DUP:
|
||||
ret=1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
case BIO_CTRL_INFO:
|
||||
case BIO_CTRL_GET:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
case BIO_CTRL_EOF:
|
||||
case BIO_CTRL_SET:
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
case BIO_CTRL_FLUSH:
|
||||
case BIO_CTRL_DUP:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
case BIO_CTRL_INFO:
|
||||
case BIO_CTRL_GET:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int null_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int null_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (str == NULL) return(0);
|
||||
return(strlen(str));
|
||||
}
|
||||
|
||||
{
|
||||
if (str == NULL)
|
||||
return (0);
|
||||
return (strlen(str));
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,16 +49,17 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu>
|
||||
/*-
|
||||
* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu>
|
||||
* Date: 22-JUL-1996
|
||||
* Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD
|
||||
* Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD
|
||||
*/
|
||||
/* VMS */
|
||||
#include <stdio.h>
|
||||
@@ -68,18 +69,26 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
#include <iodef.h> /* VMS IO$_ definitions */
|
||||
#include <iodef.h> /* VMS IO$_ definitions */
|
||||
#include <starlet.h>
|
||||
|
||||
typedef unsigned short io_channel;
|
||||
/*************************************************************************/
|
||||
struct io_status { short status, count; long flags; };
|
||||
struct io_status {
|
||||
short status, count;
|
||||
long flags;
|
||||
};
|
||||
|
||||
struct rpc_msg { /* Should have member alignment inhibited */
|
||||
char channel; /* 'A'-app data. 'R'-remote client 'G'-global */
|
||||
char function; /* 'G'-get, 'P'-put, 'C'-confirm, 'X'-close */
|
||||
unsigned short int length; /* Amount of data returned or max to return */
|
||||
char data[4092]; /* variable data */
|
||||
/* Should have member alignment inhibited */
|
||||
struct rpc_msg {
|
||||
/* 'A'-app data. 'R'-remote client 'G'-global */
|
||||
char channel;
|
||||
/* 'G'-get, 'P'-put, 'C'-confirm, 'X'-close */
|
||||
char function;
|
||||
/* Amount of data returned or max to return */
|
||||
unsigned short int length;
|
||||
/* variable data */
|
||||
char data[4092];
|
||||
};
|
||||
#define RPC_HDR_SIZE (sizeof(struct rpc_msg) - 4092)
|
||||
|
||||
@@ -88,64 +97,68 @@ struct rpc_ctx {
|
||||
struct rpc_msg msg;
|
||||
};
|
||||
|
||||
static int rtcp_write(BIO *h,const char *buf,int num);
|
||||
static int rtcp_read(BIO *h,char *buf,int size);
|
||||
static int rtcp_puts(BIO *h,const char *str);
|
||||
static int rtcp_gets(BIO *h,char *str,int size);
|
||||
static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2);
|
||||
static int rtcp_write(BIO *h, const char *buf, int num);
|
||||
static int rtcp_read(BIO *h, char *buf, int size);
|
||||
static int rtcp_puts(BIO *h, const char *str);
|
||||
static int rtcp_gets(BIO *h, char *str, int size);
|
||||
static long rtcp_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int rtcp_new(BIO *h);
|
||||
static int rtcp_free(BIO *data);
|
||||
|
||||
static BIO_METHOD rtcp_method=
|
||||
{
|
||||
BIO_TYPE_FD,
|
||||
"RTCP",
|
||||
rtcp_write,
|
||||
rtcp_read,
|
||||
rtcp_puts,
|
||||
rtcp_gets,
|
||||
rtcp_ctrl,
|
||||
rtcp_new,
|
||||
rtcp_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD rtcp_method = {
|
||||
BIO_TYPE_FD,
|
||||
"RTCP",
|
||||
rtcp_write,
|
||||
rtcp_read,
|
||||
rtcp_puts,
|
||||
rtcp_gets,
|
||||
rtcp_ctrl,
|
||||
rtcp_new,
|
||||
rtcp_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_rtcp(void)
|
||||
{
|
||||
return(&rtcp_method);
|
||||
}
|
||||
{
|
||||
return (&rtcp_method);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Decnet I/O routines.
|
||||
/*
|
||||
* Decnet I/O routines.
|
||||
*/
|
||||
|
||||
#ifdef __DECC
|
||||
#pragma message save
|
||||
#pragma message disable DOLLARID
|
||||
# pragma message save
|
||||
# pragma message disable DOLLARID
|
||||
#endif
|
||||
|
||||
static int get ( io_channel chan, char *buffer, int maxlen, int *length )
|
||||
static int get(io_channel chan, char *buffer, int maxlen, int *length)
|
||||
{
|
||||
int status;
|
||||
struct io_status iosb;
|
||||
status = sys$qiow ( 0, chan, IO$_READVBLK, &iosb, 0, 0,
|
||||
buffer, maxlen, 0, 0, 0, 0 );
|
||||
if ( (status&1) == 1 ) status = iosb.status;
|
||||
if ( (status&1) == 1 ) *length = iosb.count;
|
||||
status = sys$qiow(0, chan, IO$_READVBLK, &iosb, 0, 0,
|
||||
buffer, maxlen, 0, 0, 0, 0);
|
||||
if ((status & 1) == 1)
|
||||
status = iosb.status;
|
||||
if ((status & 1) == 1)
|
||||
*length = iosb.count;
|
||||
return status;
|
||||
}
|
||||
|
||||
static int put ( io_channel chan, char *buffer, int length )
|
||||
static int put(io_channel chan, char *buffer, int length)
|
||||
{
|
||||
int status;
|
||||
struct io_status iosb;
|
||||
status = sys$qiow ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0,
|
||||
buffer, length, 0, 0, 0, 0 );
|
||||
if ( (status&1) == 1 ) status = iosb.status;
|
||||
status = sys$qiow(0, chan, IO$_WRITEVBLK, &iosb, 0, 0,
|
||||
buffer, length, 0, 0, 0, 0);
|
||||
if ((status & 1) == 1)
|
||||
status = iosb.status;
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef __DECC
|
||||
#pragma message restore
|
||||
# pragma message restore
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -153,24 +166,26 @@ static int put ( io_channel chan, char *buffer, int length )
|
||||
static int rtcp_new(BIO *bi)
|
||||
{
|
||||
struct rpc_ctx *ctx;
|
||||
bi->init=1;
|
||||
bi->num=0;
|
||||
bi->flags = 0;
|
||||
bi->ptr=OPENSSL_malloc(sizeof(struct rpc_ctx));
|
||||
ctx = (struct rpc_ctx *) bi->ptr;
|
||||
ctx->filled = 0;
|
||||
ctx->pos = 0;
|
||||
return(1);
|
||||
bi->init = 1;
|
||||
bi->num = 0;
|
||||
bi->flags = 0;
|
||||
bi->ptr = OPENSSL_malloc(sizeof(struct rpc_ctx));
|
||||
ctx = (struct rpc_ctx *)bi->ptr;
|
||||
ctx->filled = 0;
|
||||
ctx->pos = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int rtcp_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if ( a->ptr ) OPENSSL_free ( a->ptr );
|
||||
a->ptr = NULL;
|
||||
return(1);
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->ptr)
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr = NULL;
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
static int rtcp_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int status, length;
|
||||
@@ -178,13 +193,14 @@ static int rtcp_read(BIO *b, char *out, int outl)
|
||||
/*
|
||||
* read data, return existing.
|
||||
*/
|
||||
ctx = (struct rpc_ctx *) b->ptr;
|
||||
if ( ctx->pos < ctx->filled ) {
|
||||
length = ctx->filled - ctx->pos;
|
||||
if ( length > outl ) length = outl;
|
||||
memmove ( out, &ctx->msg.data[ctx->pos], length );
|
||||
ctx->pos += length;
|
||||
return length;
|
||||
ctx = (struct rpc_ctx *)b->ptr;
|
||||
if (ctx->pos < ctx->filled) {
|
||||
length = ctx->filled - ctx->pos;
|
||||
if (length > outl)
|
||||
length = outl;
|
||||
memmove(out, &ctx->msg.data[ctx->pos], length);
|
||||
ctx->pos += length;
|
||||
return length;
|
||||
}
|
||||
/*
|
||||
* Requst more data from R channel.
|
||||
@@ -192,27 +208,29 @@ static int rtcp_read(BIO *b, char *out, int outl)
|
||||
ctx->msg.channel = 'R';
|
||||
ctx->msg.function = 'G';
|
||||
ctx->msg.length = sizeof(ctx->msg.data);
|
||||
status = put ( b->num, (char *) &ctx->msg, RPC_HDR_SIZE );
|
||||
if ( (status&1) == 0 ) {
|
||||
return -1;
|
||||
status = put(b->num, (char *)&ctx->msg, RPC_HDR_SIZE);
|
||||
if ((status & 1) == 0) {
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* Read.
|
||||
*/
|
||||
ctx->pos = ctx->filled = 0;
|
||||
status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
|
||||
if ( (status&1) == 0 ) length = -1;
|
||||
if ( ctx->msg.channel != 'R' || ctx->msg.function != 'C' ) {
|
||||
length = -1;
|
||||
status = get(b->num, (char *)&ctx->msg, sizeof(ctx->msg), &length);
|
||||
if ((status & 1) == 0)
|
||||
length = -1;
|
||||
if (ctx->msg.channel != 'R' || ctx->msg.function != 'C') {
|
||||
length = -1;
|
||||
}
|
||||
ctx->filled = length - RPC_HDR_SIZE;
|
||||
|
||||
if ( ctx->pos < ctx->filled ) {
|
||||
length = ctx->filled - ctx->pos;
|
||||
if ( length > outl ) length = outl;
|
||||
memmove ( out, ctx->msg.data, length );
|
||||
ctx->pos += length;
|
||||
return length;
|
||||
|
||||
if (ctx->pos < ctx->filled) {
|
||||
length = ctx->filled - ctx->pos;
|
||||
if (length > outl)
|
||||
length = outl;
|
||||
memmove(out, ctx->msg.data, length);
|
||||
ctx->pos += length;
|
||||
return length;
|
||||
}
|
||||
|
||||
return length;
|
||||
@@ -225,70 +243,77 @@ static int rtcp_write(BIO *b, const char *in, int inl)
|
||||
/*
|
||||
* Output data, send in chunks no larger that sizeof(ctx->msg.data).
|
||||
*/
|
||||
ctx = (struct rpc_ctx *) b->ptr;
|
||||
for ( i = 0; i < inl; i += segment ) {
|
||||
segment = inl - i;
|
||||
if ( segment > sizeof(ctx->msg.data) ) segment = sizeof(ctx->msg.data);
|
||||
ctx->msg.channel = 'R';
|
||||
ctx->msg.function = 'P';
|
||||
ctx->msg.length = segment;
|
||||
memmove ( ctx->msg.data, &in[i], segment );
|
||||
status = put ( b->num, (char *) &ctx->msg, segment + RPC_HDR_SIZE );
|
||||
if ((status&1) == 0 ) { i = -1; break; }
|
||||
ctx = (struct rpc_ctx *)b->ptr;
|
||||
for (i = 0; i < inl; i += segment) {
|
||||
segment = inl - i;
|
||||
if (segment > sizeof(ctx->msg.data))
|
||||
segment = sizeof(ctx->msg.data);
|
||||
ctx->msg.channel = 'R';
|
||||
ctx->msg.function = 'P';
|
||||
ctx->msg.length = segment;
|
||||
memmove(ctx->msg.data, &in[i], segment);
|
||||
status = put(b->num, (char *)&ctx->msg, segment + RPC_HDR_SIZE);
|
||||
if ((status & 1) == 0) {
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
|
||||
if ( ((status&1) == 0) || (length < RPC_HDR_SIZE) ) { i = -1; break; }
|
||||
if ( (ctx->msg.channel != 'R') || (ctx->msg.function != 'C') ) {
|
||||
printf("unexpected response when confirming put %c %c\n",
|
||||
ctx->msg.channel, ctx->msg.function );
|
||||
status = get(b->num, (char *)&ctx->msg, sizeof(ctx->msg), &length);
|
||||
if (((status & 1) == 0) || (length < RPC_HDR_SIZE)) {
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
if ((ctx->msg.channel != 'R') || (ctx->msg.function != 'C')) {
|
||||
printf("unexpected response when confirming put %c %c\n",
|
||||
ctx->msg.channel, ctx->msg.function);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return(i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
static long rtcp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
case BIO_CTRL_EOF:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
b->num = num;
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
case BIO_CTRL_FLUSH:
|
||||
case BIO_CTRL_DUP:
|
||||
ret=1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
case BIO_CTRL_INFO:
|
||||
case BIO_CTRL_GET:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
case BIO_CTRL_EOF:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
b->num = num;
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
case BIO_CTRL_FLUSH:
|
||||
case BIO_CTRL_DUP:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
case BIO_CTRL_INFO:
|
||||
case BIO_CTRL_GET:
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_WPENDING:
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int rtcp_gets(BIO *bp, char *buf, int size)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int rtcp_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int length;
|
||||
if (str == NULL) return(0);
|
||||
length = strlen ( str );
|
||||
if ( length == 0 ) return (0);
|
||||
return rtcp_write ( bp,str, length );
|
||||
if (str == NULL)
|
||||
return (0);
|
||||
length = strlen(str);
|
||||
if (length == 0)
|
||||
return (0);
|
||||
return rtcp_write(bp, str, length);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -34,10 +34,10 @@
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -49,7 +49,7 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
@@ -63,13 +63,13 @@
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
||||
#include <openssl/bio.h>
|
||||
# include <openssl/bio.h>
|
||||
|
||||
#ifdef WATT32
|
||||
#define sock_write SockWrite /* Watt-32 uses same names */
|
||||
#define sock_read SockRead
|
||||
#define sock_puts SockPuts
|
||||
#endif
|
||||
# ifdef WATT32
|
||||
# define sock_write SockWrite /* Watt-32 uses same names */
|
||||
# define sock_read SockRead
|
||||
# define sock_puts SockPuts
|
||||
# endif
|
||||
|
||||
static int sock_write(BIO *h, const char *buf, int num);
|
||||
static int sock_read(BIO *h, char *buf, int size);
|
||||
@@ -79,216 +79,209 @@ static int sock_new(BIO *h);
|
||||
static int sock_free(BIO *data);
|
||||
int BIO_sock_should_retry(int s);
|
||||
|
||||
static BIO_METHOD methods_sockp=
|
||||
{
|
||||
BIO_TYPE_SOCKET,
|
||||
"socket",
|
||||
sock_write,
|
||||
sock_read,
|
||||
sock_puts,
|
||||
NULL, /* sock_gets, */
|
||||
sock_ctrl,
|
||||
sock_new,
|
||||
sock_free,
|
||||
NULL,
|
||||
};
|
||||
static BIO_METHOD methods_sockp = {
|
||||
BIO_TYPE_SOCKET,
|
||||
"socket",
|
||||
sock_write,
|
||||
sock_read,
|
||||
sock_puts,
|
||||
NULL, /* sock_gets, */
|
||||
sock_ctrl,
|
||||
sock_new,
|
||||
sock_free,
|
||||
NULL,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_s_socket(void)
|
||||
{
|
||||
return(&methods_sockp);
|
||||
}
|
||||
{
|
||||
return (&methods_sockp);
|
||||
}
|
||||
|
||||
BIO *BIO_new_socket(int fd, int close_flag)
|
||||
{
|
||||
BIO *ret;
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
ret=BIO_new(BIO_s_socket());
|
||||
if (ret == NULL) return(NULL);
|
||||
BIO_set_fd(ret,fd,close_flag);
|
||||
return(ret);
|
||||
}
|
||||
ret = BIO_new(BIO_s_socket());
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
BIO_set_fd(ret, fd, close_flag);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int sock_new(BIO *bi)
|
||||
{
|
||||
bi->init=0;
|
||||
bi->num=0;
|
||||
bi->ptr=NULL;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
{
|
||||
bi->init = 0;
|
||||
bi->num = 0;
|
||||
bi->ptr = NULL;
|
||||
bi->flags = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int sock_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if (a->init)
|
||||
{
|
||||
SHUTDOWN2(a->num);
|
||||
}
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int sock_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
{
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
if (a->shutdown) {
|
||||
if (a->init) {
|
||||
SHUTDOWN2(a->num);
|
||||
}
|
||||
a->init = 0;
|
||||
a->flags = 0;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (out != NULL)
|
||||
{
|
||||
clear_socket_error();
|
||||
ret=readsocket(b->num,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
static int sock_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (out != NULL) {
|
||||
clear_socket_error();
|
||||
ret = readsocket(b->num, out, outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0) {
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int sock_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret;
|
||||
|
||||
clear_socket_error();
|
||||
ret=writesocket(b->num,in,inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_write(b);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
{
|
||||
int ret;
|
||||
|
||||
clear_socket_error();
|
||||
ret = writesocket(b->num, in, inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0) {
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_write(b);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
int *ip;
|
||||
{
|
||||
long ret = 1;
|
||||
int *ip;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_C_SET_FD:
|
||||
sock_free(b);
|
||||
b->num= *((int *)ptr);
|
||||
b->shutdown=(int)num;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init)
|
||||
{
|
||||
ip=(int *)ptr;
|
||||
if (ip != NULL) *ip=b->num;
|
||||
ret=b->num;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret=1;
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
switch (cmd) {
|
||||
case BIO_C_SET_FD:
|
||||
sock_free(b);
|
||||
b->num = *((int *)ptr);
|
||||
b->shutdown = (int)num;
|
||||
b->init = 1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init) {
|
||||
ip = (int *)ptr;
|
||||
if (ip != NULL)
|
||||
*ip = b->num;
|
||||
ret = b->num;
|
||||
} else
|
||||
ret = -1;
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret = 1;
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int sock_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
{
|
||||
int n, ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=sock_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
n = strlen(str);
|
||||
ret = sock_write(bp, str, n);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int BIO_sock_should_retry(int i)
|
||||
{
|
||||
int err;
|
||||
{
|
||||
int err;
|
||||
|
||||
if ((i == 0) || (i == -1))
|
||||
{
|
||||
err=get_last_socket_error();
|
||||
if ((i == 0) || (i == -1)) {
|
||||
err = get_last_socket_error();
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
|
||||
if ((i == -1) && (err == 0))
|
||||
return(1);
|
||||
#endif
|
||||
# if defined(OPENSSL_SYS_WINDOWS) && 0/* more microsoft stupidity? perhaps
|
||||
* not? Ben 4/1/99 */
|
||||
if ((i == -1) && (err == 0))
|
||||
return (1);
|
||||
# endif
|
||||
|
||||
return(BIO_sock_non_fatal_error(err));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
return (BIO_sock_non_fatal_error(err));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int BIO_sock_non_fatal_error(int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE)
|
||||
# if defined(WSAEWOULDBLOCK)
|
||||
case WSAEWOULDBLOCK:
|
||||
# endif
|
||||
{
|
||||
switch (err) {
|
||||
# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE)
|
||||
# if defined(WSAEWOULDBLOCK)
|
||||
case WSAEWOULDBLOCK:
|
||||
# endif
|
||||
|
||||
# if 0 /* This appears to always be an error */
|
||||
# if defined(WSAENOTCONN)
|
||||
case WSAENOTCONN:
|
||||
# if 0 /* This appears to always be an error */
|
||||
# if defined(WSAENOTCONN)
|
||||
case WSAENOTCONN:
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef EWOULDBLOCK
|
||||
# ifdef WSAEWOULDBLOCK
|
||||
# if WSAEWOULDBLOCK != EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
# ifdef EWOULDBLOCK
|
||||
# ifdef WSAEWOULDBLOCK
|
||||
# if WSAEWOULDBLOCK != EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
# else
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
# else
|
||||
case EWOULDBLOCK:
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ENOTCONN)
|
||||
case ENOTCONN:
|
||||
#endif
|
||||
|
||||
#ifdef EINTR
|
||||
case EINTR:
|
||||
#endif
|
||||
|
||||
#ifdef EAGAIN
|
||||
# if EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
# if defined(ENOTCONN)
|
||||
case ENOTCONN:
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef EPROTO
|
||||
case EPROTO:
|
||||
#endif
|
||||
# ifdef EINTR
|
||||
case EINTR:
|
||||
# endif
|
||||
|
||||
#ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
#endif
|
||||
# ifdef EAGAIN
|
||||
# if EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef EALREADY
|
||||
case EALREADY:
|
||||
#endif
|
||||
return(1);
|
||||
/* break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
# ifdef EPROTO
|
||||
case EPROTO:
|
||||
# endif
|
||||
|
||||
#endif /* #ifndef OPENSSL_NO_SOCK */
|
||||
# ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
# endif
|
||||
|
||||
# ifdef EALREADY
|
||||
case EALREADY:
|
||||
# endif
|
||||
return (1);
|
||||
/* break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* #ifndef OPENSSL_NO_SOCK */
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user