Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
a1ad253f
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
接近 2 年 前同步成功
通知
12
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看板
提交
a1ad253f
编写于
11月 04, 2005
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eliminate remaining calls to stat in apps/apps.c and unify WIN32_rename for
all Windows targets.
上级
ffa10187
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
106 deletion
+91
-106
apps/apps.c
apps/apps.c
+91
-101
apps/apps.h
apps/apps.h
+0
-5
未找到文件。
apps/apps.c
浏览文件 @
a1ad253f
...
@@ -113,8 +113,8 @@
...
@@ -113,8 +113,8 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <openssl/err.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/x509v3.h>
...
@@ -130,18 +130,15 @@
...
@@ -130,18 +130,15 @@
#endif
#endif
#include <openssl/bn.h>
#include <openssl/bn.h>
#ifdef _WIN32
#include <windows.h>
#ifdef fileno
#undef fileno
#define fileno(a) (int)_fileno(a)
#endif
#endif
#define NON_MAIN
#define NON_MAIN
#include "apps.h"
#include "apps.h"
#undef NON_MAIN
#undef NON_MAIN
#ifdef _WIN32
static
int
WIN32_rename
(
const
char
*
from
,
const
char
*
to
);
#define rename(from,to) WIN32_rename((from),(to))
#endif
typedef
struct
{
typedef
struct
{
const
char
*
name
;
const
char
*
name
;
unsigned
long
flag
;
unsigned
long
flag
;
...
@@ -170,18 +167,23 @@ int args_from_file(char *file, int *argc, char **argv[])
...
@@ -170,18 +167,23 @@ int args_from_file(char *file, int *argc, char **argv[])
static
char
*
buf
=
NULL
;
static
char
*
buf
=
NULL
;
static
char
**
arg
=
NULL
;
static
char
**
arg
=
NULL
;
char
*
p
;
char
*
p
;
struct
stat
stbuf
;
if
(
stat
(
file
,
&
stbuf
)
<
0
)
return
(
0
);
fp
=
fopen
(
file
,
"r"
);
fp
=
fopen
(
file
,
"r"
);
if
(
fp
==
NULL
)
if
(
fp
==
NULL
)
return
(
0
);
return
(
0
);
if
(
fseek
(
fp
,
0
,
SEEK_END
)
==
0
)
len
=
ftell
(
fp
),
rewind
(
fp
);
else
len
=-
1
;
if
(
len
<=
0
)
{
fclose
(
fp
);
return
(
0
);
}
*
argc
=
0
;
*
argc
=
0
;
*
argv
=
NULL
;
*
argv
=
NULL
;
len
=
(
unsigned
int
)
stbuf
.
st_size
;
if
(
buf
!=
NULL
)
OPENSSL_free
(
buf
);
if
(
buf
!=
NULL
)
OPENSSL_free
(
buf
);
buf
=
(
char
*
)
OPENSSL_malloc
(
len
+
1
);
buf
=
(
char
*
)
OPENSSL_malloc
(
len
+
1
);
if
(
buf
==
NULL
)
return
(
0
);
if
(
buf
==
NULL
)
return
(
0
);
...
@@ -1623,7 +1625,6 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
...
@@ -1623,7 +1625,6 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
{
{
char
buf
[
5
][
BSIZE
];
char
buf
[
5
][
BSIZE
];
int
i
,
j
;
int
i
,
j
;
struct
stat
sb
;
i
=
strlen
(
serialfile
)
+
strlen
(
old_suffix
);
i
=
strlen
(
serialfile
)
+
strlen
(
old_suffix
);
j
=
strlen
(
serialfile
)
+
strlen
(
new_suffix
);
j
=
strlen
(
serialfile
)
+
strlen
(
new_suffix
);
...
@@ -1648,30 +1649,21 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
...
@@ -1648,30 +1649,21 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
j
=
BIO_snprintf
(
buf
[
1
],
sizeof
buf
[
1
],
"%s-%s"
,
j
=
BIO_snprintf
(
buf
[
1
],
sizeof
buf
[
1
],
"%s-%s"
,
serialfile
,
old_suffix
);
serialfile
,
old_suffix
);
#endif
#endif
if
(
stat
(
serialfile
,
&
sb
)
<
0
)
#ifdef RL_DEBUG
{
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
if
(
errno
!=
ENOENT
serialfile
,
buf
[
1
]);
#endif
if
(
rename
(
serialfile
,
buf
[
1
])
<
0
&&
errno
!=
ENOENT
#ifdef ENOTDIR
#ifdef ENOTDIR
&&
errno
!=
ENOTDIR
&&
errno
!=
ENOTDIR
#endif
#endif
)
)
{
goto
err
;
}
else
{
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
serialfile
,
buf
[
1
]);
#endif
if
(
rename
(
serialfile
,
buf
[
1
])
<
0
)
{
BIO_printf
(
bio_err
,
BIO_printf
(
bio_err
,
"unable to rename %s to %s
\n
"
,
"unable to rename %s to %s
\n
"
,
serialfile
,
buf
[
1
]);
serialfile
,
buf
[
1
]);
perror
(
"reason"
);
perror
(
"reason"
);
goto
err
;
goto
err
;
}
}
}
#ifdef RL_DEBUG
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
buf
[
0
],
serialfile
);
buf
[
0
],
serialfile
);
...
@@ -1894,7 +1886,6 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
...
@@ -1894,7 +1886,6 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
{
{
char
buf
[
5
][
BSIZE
];
char
buf
[
5
][
BSIZE
];
int
i
,
j
;
int
i
,
j
;
struct
stat
sb
;
i
=
strlen
(
dbfile
)
+
strlen
(
old_suffix
);
i
=
strlen
(
dbfile
)
+
strlen
(
old_suffix
);
j
=
strlen
(
dbfile
)
+
strlen
(
new_suffix
);
j
=
strlen
(
dbfile
)
+
strlen
(
new_suffix
);
...
@@ -1938,30 +1929,21 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
...
@@ -1938,30 +1929,21 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
j
=
BIO_snprintf
(
buf
[
3
],
sizeof
buf
[
3
],
"%s-attr-%s"
,
j
=
BIO_snprintf
(
buf
[
3
],
sizeof
buf
[
3
],
"%s-attr-%s"
,
dbfile
,
old_suffix
);
dbfile
,
old_suffix
);
#endif
#endif
if
(
stat
(
dbfile
,
&
sb
)
<
0
)
{
if
(
errno
!=
ENOENT
#ifdef ENOTDIR
&&
errno
!=
ENOTDIR
#endif
)
goto
err
;
}
else
{
#ifdef RL_DEBUG
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
dbfile
,
buf
[
1
]);
dbfile
,
buf
[
1
]);
#endif
#endif
if
(
rename
(
dbfile
,
buf
[
1
])
<
0
)
if
(
rename
(
dbfile
,
buf
[
1
])
<
0
&&
errno
!=
ENOENT
{
#ifdef ENOTDIR
&&
errno
!=
ENOTDIR
#endif
)
{
BIO_printf
(
bio_err
,
BIO_printf
(
bio_err
,
"unable to rename %s to %s
\n
"
,
"unable to rename %s to %s
\n
"
,
dbfile
,
buf
[
1
]);
dbfile
,
buf
[
1
]);
perror
(
"reason"
);
perror
(
"reason"
);
goto
err
;
goto
err
;
}
}
}
#ifdef RL_DEBUG
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
buf
[
0
],
dbfile
);
buf
[
0
],
dbfile
);
...
@@ -1975,23 +1957,15 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
...
@@ -1975,23 +1957,15 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
rename
(
buf
[
1
],
dbfile
);
rename
(
buf
[
1
],
dbfile
);
goto
err
;
goto
err
;
}
}
if
(
stat
(
buf
[
4
],
&
sb
)
<
0
)
{
if
(
errno
!=
ENOENT
#ifdef ENOTDIR
&&
errno
!=
ENOTDIR
#endif
)
goto
err
;
}
else
{
#ifdef RL_DEBUG
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
buf
[
4
],
buf
[
3
]);
buf
[
4
],
buf
[
3
]);
#endif
#endif
if
(
rename
(
buf
[
4
],
buf
[
3
])
<
0
)
if
(
rename
(
buf
[
4
],
buf
[
3
])
<
0
&&
errno
!=
ENOENT
{
#ifdef ENOTDIR
&&
errno
!=
ENOTDIR
#endif
)
{
BIO_printf
(
bio_err
,
BIO_printf
(
bio_err
,
"unable to rename %s to %s
\n
"
,
"unable to rename %s to %s
\n
"
,
buf
[
4
],
buf
[
3
]);
buf
[
4
],
buf
[
3
]);
...
@@ -2000,7 +1974,6 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
...
@@ -2000,7 +1974,6 @@ int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
rename
(
buf
[
1
],
dbfile
);
rename
(
buf
[
1
],
dbfile
);
goto
err
;
goto
err
;
}
}
}
#ifdef RL_DEBUG
#ifdef RL_DEBUG
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
BIO_printf
(
bio_err
,
"DEBUG: renaming
\"
%s
\"
to
\"
%s
\"\n
"
,
buf
[
2
],
buf
[
4
]);
buf
[
2
],
buf
[
4
]);
...
@@ -2195,45 +2168,6 @@ error:
...
@@ -2195,45 +2168,6 @@ error:
return
NULL
;
return
NULL
;
}
}
/* This code MUST COME AFTER anything that uses rename() */
#ifdef OPENSSL_SYS_WIN32
int
WIN32_rename
(
const
char
*
from
,
const
char
*
to
)
{
#ifndef OPENSSL_SYS_WINCE
/* Windows rename gives an error if 'to' exists, so delete it
* first and ignore file not found errror
*/
if
((
remove
(
to
)
!=
0
)
&&
(
errno
!=
ENOENT
))
return
-
1
;
#undef rename
return
rename
(
from
,
to
);
#else
/* convert strings to UNICODE */
{
BOOL
result
=
FALSE
;
WCHAR
*
wfrom
;
WCHAR
*
wto
;
int
i
;
wfrom
=
malloc
((
strlen
(
from
)
+
1
)
*
2
);
wto
=
malloc
((
strlen
(
to
)
+
1
)
*
2
);
if
(
wfrom
!=
NULL
&&
wto
!=
NULL
)
{
for
(
i
=
0
;
i
<
(
int
)
strlen
(
from
)
+
1
;
i
++
)
wfrom
[
i
]
=
(
short
)
from
[
i
];
for
(
i
=
0
;
i
<
(
int
)
strlen
(
to
)
+
1
;
i
++
)
wto
[
i
]
=
(
short
)
to
[
i
];
result
=
MoveFile
(
wfrom
,
wto
);
}
if
(
wfrom
!=
NULL
)
free
(
wfrom
);
if
(
wto
!=
NULL
)
free
(
wto
);
return
result
;
}
#endif
}
#endif
int
args_verify
(
char
***
pargs
,
int
*
pargc
,
int
args_verify
(
char
***
pargs
,
int
*
pargc
,
int
*
badarg
,
BIO
*
err
,
X509_VERIFY_PARAM
**
pm
)
int
*
badarg
,
BIO
*
err
,
X509_VERIFY_PARAM
**
pm
)
{
{
...
@@ -2374,6 +2308,62 @@ void policies_print(BIO *out, X509_STORE_CTX *ctx)
...
@@ -2374,6 +2308,62 @@ void policies_print(BIO *out, X509_STORE_CTX *ctx)
}
}
#if defined(_WIN32)
#if defined(_WIN32)
# ifdef fileno
# undef fileno
# define fileno(a) (int)_fileno(a)
# endif
# include <windows.h>
# include <tchar.h>
static
int
WIN32_rename
(
const
char
*
from
,
const
char
*
to
)
{
TCHAR
*
tfrom
=
NULL
,
*
tto
;
DWORD
err
;
int
ret
=
0
;
if
(
sizeof
(
TCHAR
)
==
1
)
{
tfrom
=
(
TCHAR
*
)
from
;
tto
=
(
TCHAR
*
)
to
;
}
else
/* UNICODE path */
{
size_t
i
,
flen
=
strlen
(
from
)
+
1
,
tlen
=
strlen
(
to
)
+
1
;
tfrom
=
(
TCHAR
*
)
malloc
(
sizeof
(
TCHAR
)
*
(
flen
+
tlen
));
if
(
tfrom
==
NULL
)
goto
err
;
tto
=
tfrom
+
flen
;
#if !defined(_WIN32_WCE) || _WIN32_WCE>=101
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
from
,
flen
,(
WCHAR
*
)
tfrom
,
flen
))
#endif
for
(
i
=
0
;
i
<
flen
;
i
++
)
tfrom
[
i
]
=
(
TCHAR
)
from
[
i
];
#if !defined(_WIN32_WCE) || _WIN32_WCE>=101
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
to
,
tlen
,(
WCHAR
*
)
tto
,
tlen
))
#endif
for
(
i
=
0
;
i
<
tlen
;
i
++
)
tto
[
i
]
=
(
TCHAR
)
to
[
i
];
}
if
(
MoveFile
(
tfrom
,
tto
))
goto
ok
;
err
=
GetLastError
();
if
(
err
==
ERROR_ALREADY_EXISTS
||
err
==
ERROR_FILE_EXISTS
)
{
if
(
DeleteFile
(
tto
)
&&
MoveFile
(
tfrom
,
tto
))
goto
ok
;
err
=
GetLastError
();
}
if
(
err
==
ERROR_FILE_NOT_FOUND
||
err
==
ERROR_PATH_NOT_FOUND
)
errno
=
ENOENT
;
else
if
(
err
==
ERROR_ACCESS_DENIED
)
errno
=
EACCES
;
else
errno
=
EINVAL
;
/* we could map more codes... */
err:
ret
=-
1
;
ok:
if
(
tfrom
!=
NULL
&&
tfrom
!=
(
TCHAR
*
)
from
)
free
(
tfrom
);
return
ret
;
}
int
app_isdir
(
const
char
*
name
)
int
app_isdir
(
const
char
*
name
)
{
{
HANDLE
hList
;
HANDLE
hList
;
...
...
apps/apps.h
浏览文件 @
a1ad253f
...
@@ -134,11 +134,6 @@ long app_RAND_load_files(char *file); /* `file' is a list of files to read,
...
@@ -134,11 +134,6 @@ long app_RAND_load_files(char *file); /* `file' is a list of files to read,
* (see e_os.h). The string is
* (see e_os.h). The string is
* destroyed! */
* destroyed! */
#ifdef OPENSSL_SYS_WIN32
#define rename(from,to) WIN32_rename((from),(to))
int
WIN32_rename
(
const
char
*
oldname
,
const
char
*
newname
);
#endif
#ifndef MONOLITH
#ifndef MONOLITH
#define MAIN(a,v) main(a,v)
#define MAIN(a,v) main(a,v)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录