Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
ffa10187
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
12 个月 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ffa10187
编写于
11月 04, 2005
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eliminate dependency on read/write/stat in apps under _WIN32.
上级
4d24b4c4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
61 deletion
+101
-61
apps/apps.c
apps/apps.c
+89
-0
apps/apps.h
apps/apps.h
+3
-0
apps/ca.c
apps/ca.c
+1
-11
apps/crl2p7.c
apps/crl2p7.c
+0
-8
apps/s_client.c
apps/s_client.c
+4
-13
apps/s_server.c
apps/s_server.c
+4
-29
未找到文件。
apps/apps.c
浏览文件 @
ffa10187
...
...
@@ -130,6 +130,14 @@
#endif
#include <openssl/bn.h>
#ifdef _WIN32
#include <windows.h>
#ifdef fileno
#undef fileno
#define fileno(a) (int)_fileno(a)
#endif
#endif
#define NON_MAIN
#include "apps.h"
#undef NON_MAIN
...
...
@@ -773,7 +781,9 @@ X509 *load_cert(BIO *err, const char *file, int format,
if
(
file
==
NULL
)
{
#ifdef _IONBF
setvbuf
(
stdin
,
NULL
,
_IONBF
,
0
);
#endif
BIO_set_fp
(
cert
,
stdin
,
BIO_NOCLOSE
);
}
else
...
...
@@ -865,7 +875,9 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
}
if
(
file
==
NULL
&&
maybe_stdin
)
{
#ifdef _IONBF
setvbuf
(
stdin
,
NULL
,
_IONBF
,
0
);
#endif
BIO_set_fp
(
key
,
stdin
,
BIO_NOCLOSE
);
}
else
...
...
@@ -947,7 +959,9 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
}
if
(
file
==
NULL
&&
maybe_stdin
)
{
#ifdef _IONBF
setvbuf
(
stdin
,
NULL
,
_IONBF
,
0
);
#endif
BIO_set_fp
(
key
,
stdin
,
BIO_NOCLOSE
);
}
else
...
...
@@ -2358,3 +2372,78 @@ void policies_print(BIO *out, X509_STORE_CTX *ctx)
if
(
free_out
)
BIO_free
(
out
);
}
#if defined(_WIN32)
int
app_isdir
(
const
char
*
name
)
{
HANDLE
hList
;
WIN32_FIND_DATA
FileData
;
#if defined(UNICODE) || defined(_UNICODE)
size_t
i
,
len_0
=
strlen
(
name
)
+
1
;
if
(
len_0
>
sizeof
(
FileData
.
cFileName
)
/
sizeof
(
FileData
.
cFileName
[
0
]))
return
-
1
;
#if !defined(_WIN32_WCE) || _WIN32_WCE>=101
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
len_0
,
FileData
.
cFileName
,
len_0
))
#endif
for
(
i
=
0
;
i
<
len_0
;
i
++
)
FileData
.
cFileName
[
i
]
=
(
WCHAR
)
name
[
i
];
hList
=
FindFirstFile
(
FileData
.
cFileName
,
&
FileData
);
#else
hList
=
FindFirstFile
(
name
,
&
FileData
);
#endif
if
(
hList
==
INVALID_HANDLE_VALUE
)
return
-
1
;
FindClose
(
hList
);
return
((
FileData
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
!=
0
);
}
#else
#include <sys/stat.h>
#ifndef S_ISDIR
# if defined(_S_IFMT) && defined(_S_IFDIR)
# define S_ISDIR(a) (((a) & _S_IFMT) == _S_IFDIR)
# else
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
# endif
#endif
int
app_isdir
(
const
char
*
name
)
{
#if defined(S_ISDIR)
struct
stat
st
;
if
(
stat
(
name
,
&
st
)
==
0
)
return
S_ISDIR
(
st
.
st_mode
);
else
return
-
1
;
#else
return
-
1
;
#endif
}
#endif
#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
int
raw_read_stdin
(
void
*
buf
,
int
siz
)
{
DWORD
n
;
if
(
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
buf
,
siz
,
&
n
,
NULL
))
return
(
n
);
else
return
(
-
1
);
}
#else
int
raw_read_stdin
(
void
*
buf
,
int
siz
)
{
return
read
(
fileno
(
stdin
),
buf
,
siz
);
}
#endif
#if defined(_WIN32) && defined(STD_OUTPUT_HANDLE)
int
raw_write_stdout
(
void
*
buf
,
int
siz
)
{
DWORD
n
;
if
(
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
buf
,
siz
,
&
n
,
NULL
))
return
(
n
);
else
return
(
-
1
);
}
#else
int
raw_write_stdout
(
const
void
*
buf
,
int
siz
)
{
return
write
(
fileno
(
stdout
),
buf
,
siz
);
}
#endif
apps/apps.h
浏览文件 @
ffa10187
...
...
@@ -316,4 +316,7 @@ void policies_print(BIO *out, X509_STORE_CTX *ctx);
#define SERIAL_RAND_BITS 64
int
app_isdir
(
const
char
*
);
int
raw_read_stdin
(
void
*
,
int
);
int
raw_write_stdout
(
const
void
*
,
int
);
#endif
apps/ca.c
浏览文件 @
ffa10187
...
...
@@ -63,7 +63,6 @@
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <openssl/conf.h>
#include <openssl/bio.h>
#include <openssl/err.h>
...
...
@@ -826,7 +825,6 @@ bad:
/* lookup where to write new certificates */
if
((
outdir
==
NULL
)
&&
(
req
))
{
struct
stat
sb
;
if
((
outdir
=
NCONF_get_string
(
conf
,
section
,
ENV_NEW_CERTS_DIR
))
==
NULL
)
...
...
@@ -852,20 +850,12 @@ bad:
goto
err
;
}
if
(
stat
(
outdir
,
&
sb
)
!=
0
)
{
BIO_printf
(
bio_err
,
"unable to stat(%s)
\n
"
,
outdir
);
perror
(
outdir
);
goto
err
;
}
#ifdef S_IFDIR
if
(
!
(
sb
.
st_mode
&
S_IFDIR
))
if
(
app_isdir
(
outdir
)
<=
0
)
{
BIO_printf
(
bio_err
,
"%s need to be a directory
\n
"
,
outdir
);
perror
(
outdir
);
goto
err
;
}
#endif
#endif
}
...
...
apps/crl2p7.c
浏览文件 @
ffa10187
...
...
@@ -63,7 +63,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "apps.h"
#include <openssl/err.h>
#include <openssl/evp.h>
...
...
@@ -295,19 +294,12 @@ end:
*/
static
int
add_certs_from_file
(
STACK_OF
(
X509
)
*
stack
,
char
*
certfile
)
{
struct
stat
st
;
BIO
*
in
=
NULL
;
int
count
=
0
;
int
ret
=
-
1
;
STACK_OF
(
X509_INFO
)
*
sk
=
NULL
;
X509_INFO
*
xi
;
if
((
stat
(
certfile
,
&
st
)
!=
0
))
{
BIO_printf
(
bio_err
,
"unable to load the file, %s
\n
"
,
certfile
);
goto
end
;
}
in
=
BIO_new
(
BIO_s_file
());
if
((
in
==
NULL
)
||
(
BIO_read_filename
(
in
,
certfile
)
<=
0
))
{
...
...
apps/s_client.c
浏览文件 @
ffa10187
...
...
@@ -137,15 +137,6 @@ typedef unsigned int u_int;
#include "s_apps.h"
#include "timeouts.h"
#ifdef OPENSSL_SYS_WINCE
/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
#ifdef fileno
#undef fileno
#endif
#define fileno(a) (int)_fileno(a)
#endif
#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
...
...
@@ -926,7 +917,7 @@ re_start:
#ifdef CHARSET_EBCDIC
ascii2ebcdic
(
&
(
sbuf
[
sbuf_off
]),
&
(
sbuf
[
sbuf_off
]),
sbuf_len
);
#endif
i
=
write
(
fileno
(
stdout
),
&
(
sbuf
[
sbuf_off
]),
sbuf_len
);
i
=
raw_write_stdout
(
&
(
sbuf
[
sbuf_off
]),
sbuf_len
);
if
(
i
<=
0
)
{
...
...
@@ -1004,7 +995,7 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
else
if
((
_kbhit
())
||
(
WAIT_OBJECT_0
==
WaitForSingleObject
(
GetStdHandle
(
STD_INPUT_HANDLE
),
0
)))
#endif
#elif defined (OPENSSL_SYS_NETWARE)
else
if
(
_kbhit
())
else
if
(
_kbhit
())
#else
else
if
(
FD_ISSET
(
fileno
(
stdin
),
&
readfds
))
#endif
...
...
@@ -1013,7 +1004,7 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
{
int
j
,
lf_num
;
i
=
r
ead
(
fileno
(
stdin
),
cbuf
,
BUFSIZZ
/
2
);
i
=
r
aw_read_stdin
(
cbuf
,
BUFSIZZ
/
2
);
lf_num
=
0
;
/* both loops are skipped when i <= 0 */
for
(
j
=
0
;
j
<
i
;
j
++
)
...
...
@@ -1032,7 +1023,7 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
assert
(
lf_num
==
0
);
}
else
i
=
r
ead
(
fileno
(
stdin
),
cbuf
,
BUFSIZZ
);
i
=
r
aw_read_stdin
(
cbuf
,
BUFSIZZ
);
if
((
!
c_ign_eof
)
&&
((
i
<=
0
)
||
(
cbuf
[
0
]
==
'Q'
)))
{
...
...
apps/s_server.c
浏览文件 @
ffa10187
...
...
@@ -125,7 +125,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <openssl/e_os2.h>
#ifdef OPENSSL_NO_STDIO
#define APPS_WIN16
...
...
@@ -162,14 +161,6 @@ typedef unsigned int u_int;
#include "s_apps.h"
#include "timeouts.h"
#ifdef OPENSSL_SYS_WINCE
/* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
#ifdef fileno
#undef fileno
#endif
#define fileno(a) (int)_fileno(a)
#endif
#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
...
...
@@ -195,14 +186,6 @@ static DH *get_dh512(void);
static
void
s_server_init
(
void
);
#endif
#ifndef S_ISDIR
# if defined(_S_IFMT) && defined(_S_IFDIR)
# define S_ISDIR(a) (((a) & _S_IFMT) == _S_IFDIR)
# else
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
# endif
#endif
#ifndef OPENSSL_NO_DH
static
unsigned
char
dh512_p
[]
=
{
0xDA
,
0x58
,
0x3C
,
0x16
,
0xD9
,
0x85
,
0x22
,
0x89
,
0xD0
,
0xE4
,
0xAF
,
0x75
,
...
...
@@ -1293,7 +1276,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
{
int
j
,
lf_num
;
i
=
r
ead
(
fileno
(
stdin
),
buf
,
bufsize
/
2
);
i
=
r
aw_read_stdin
(
buf
,
bufsize
/
2
);
lf_num
=
0
;
/* both loops are skipped when i <= 0 */
for
(
j
=
0
;
j
<
i
;
j
++
)
...
...
@@ -1312,7 +1295,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
assert
(
lf_num
==
0
);
}
else
i
=
r
ead
(
fileno
(
stdin
),
buf
,
bufsize
);
i
=
r
aw_read_stdin
(
buf
,
bufsize
);
if
(
!
s_quiet
)
{
if
((
i
<=
0
)
||
(
buf
[
0
]
==
'Q'
))
...
...
@@ -1428,7 +1411,7 @@ again:
#ifdef CHARSET_EBCDIC
ascii2ebcdic
(
buf
,
buf
,
i
);
#endif
write
(
fileno
(
stdout
),
buf
,
raw_write_stdout
(
buf
,
(
unsigned
int
)
i
);
if
(
SSL_pending
(
con
))
goto
again
;
break
;
...
...
@@ -1580,7 +1563,6 @@ static int www_body(char *hostname, int s, unsigned char *context)
char
*
buf
=
NULL
;
int
ret
=
1
;
int
i
,
j
,
k
,
blank
,
dot
;
struct
stat
st_buf
;
SSL
*
con
;
SSL_CIPHER
*
c
;
BIO
*
io
,
*
ssl_bio
,
*
sbio
;
...
...
@@ -1845,14 +1827,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
#endif
/* if a directory, do the index thang */
if
(
stat
(
p
,
&
st_buf
)
<
0
)
{
BIO_puts
(
io
,
text
);
BIO_printf
(
io
,
"Error accessing '%s'
\r\n
"
,
p
);
ERR_print_errors
(
io
);
break
;
}
if
(
S_ISDIR
(
st_buf
.
st_mode
))
if
(
app_isdir
(
p
)
>
0
)
{
#if 0 /* must check buffer size */
strcat(p,"/index.html");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录