Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
cd1a6685
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd1a6685
编写于
5月 13, 2020
作者:
W
WangFengTu
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix panic when login to docker.io
and fix some memory leak Signed-off-by:
N
WangFengTu
<
wangfengtu@huawei.com
>
上级
a313fe80
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
77 addition
and
25 deletion
+77
-25
CI/test_cases/basic_cases/registry.bash
CI/test_cases/basic_cases/registry.bash
+27
-1
src/http/parser.c
src/http/parser.c
+4
-0
src/http/parser.h
src/http/parser.h
+1
-1
src/image/oci/registry/auths.c
src/image/oci/registry/auths.c
+8
-0
src/image/oci/registry/registry.c
src/image/oci/registry/registry.c
+34
-22
src/image/oci/registry/registry_apiv2.c
src/image/oci/registry/registry_apiv2.c
+3
-1
未找到文件。
CI/test_cases/basic_cases/registry.bash
浏览文件 @
cd1a6685
...
@@ -32,9 +32,35 @@ function isula_pull()
...
@@ -32,9 +32,35 @@ function isula_pull()
fn_check_eq
"
$?
"
"0"
"isula inspect busybox"
fn_check_eq
"
$?
"
"0"
"isula inspect busybox"
}
}
function
isula_login
()
{
isula login
-u
test
-p
test
hub-mirror.c.163.com
fn_check_eq
"
$?
"
"0"
"isula login -u test -p test hub-mirror.c.163.com"
# double login for memory leak check
isula login
-u
test
-p
test
hub-mirror.c.163.com
fn_check_eq
"
$?
"
"0"
"isula login -u test -p test hub-mirror.c.163.com"
# use username/password to pull busybox for memmory leak check
isula pull busybox
fn_check_eq
"
$?
"
"0"
"isula pull busybox"
}
function
isula_logout
()
{
isula
logout
hub-mirror.c.163.com
fn_check_eq
"
$?
"
"0"
"isula logout hub-mirror.c.163.com"
# double logout for memory leak check
isula
logout
hub-mirror.c.163.com
fn_check_eq
"
$?
"
"0"
"isula logout hub-mirror.c.163.com"
}
function
do_test_t
()
function
do_test_t
()
{
{
isula_pull
isula_pull
isula_login
isula_logout
return
$TC_RET_T
return
$TC_RET_T
}
}
...
@@ -47,4 +73,4 @@ if [ $? -ne 0 ];then
...
@@ -47,4 +73,4 @@ if [ $? -ne 0 ];then
let
"ret=
$ret
+ 1"
let
"ret=
$ret
+ 1"
fi
fi
show_result
$ret
"basic
pull
"
show_result
$ret
"basic
registry
"
src/http/parser.c
浏览文件 @
cd1a6685
...
@@ -79,6 +79,10 @@ static int parser_cb_header_field(http_parser *parser, const char *buf,
...
@@ -79,6 +79,10 @@ static int parser_cb_header_field(http_parser *parser, const char *buf,
struct
parsed_http_message
*
m
=
parser
->
data
;
struct
parsed_http_message
*
m
=
parser
->
data
;
if
(
m
->
last_header_element
!=
FIELD
)
{
if
(
m
->
last_header_element
!=
FIELD
)
{
if
(
m
->
num_headers
+
1
>=
MAX_HEADERS
)
{
ERROR
(
"too many headers exceeded maxium number %d"
,
MAX_HEADERS
);
return
-
1
;
}
m
->
num_headers
++
;
m
->
num_headers
++
;
}
}
...
...
src/http/parser.h
浏览文件 @
cd1a6685
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
#undef FALSE
#undef FALSE
#define FALSE 0
#define FALSE 0
#define MAX_HEADERS
13
#define MAX_HEADERS
30
#define MAX_ELEMENT_SIZE 2048
#define MAX_ELEMENT_SIZE 2048
#define MAX_CHUNKS 16
#define MAX_CHUNKS 16
...
...
src/image/oci/registry/auths.c
浏览文件 @
cd1a6685
...
@@ -100,6 +100,8 @@ static int decode_auth(char *encoded, char **username, char **password)
...
@@ -100,6 +100,8 @@ static int decode_auth(char *encoded, char **username, char **password)
(
void
)
memset
(
auth_parts
[
1
],
0
,
strlen
(
auth_parts
[
1
]));
(
void
)
memset
(
auth_parts
[
1
],
0
,
strlen
(
auth_parts
[
1
]));
out:
out:
free_sensitive_string
((
char
*
)
auth
);
auth
=
NULL
;
free_sensitive_string
((
char
*
)
decoded
);
free_sensitive_string
((
char
*
)
decoded
);
decoded
=
NULL
;
decoded
=
NULL
;
util_free_array
(
auth_parts
);
util_free_array
(
auth_parts
);
...
@@ -345,6 +347,8 @@ static int write_auth_file(char *content)
...
@@ -345,6 +347,8 @@ static int write_auth_file(char *content)
}
}
out:
out:
free
(
auths_dir
);
auths_dir
=
NULL
;
return
ret
;
return
ret
;
}
}
...
@@ -411,6 +415,8 @@ int auths_save(char *host, char *username, char *password)
...
@@ -411,6 +415,8 @@ int auths_save(char *host, char *username, char *password)
}
}
out:
out:
free
(
json
);
json
=
NULL
;
free_registry_auths
(
auths
);
free_registry_auths
(
auths
);
auths
=
NULL
;
auths
=
NULL
;
free_defs_map_string_object_auths
(
element
);
free_defs_map_string_object_auths
(
element
);
...
@@ -502,6 +508,8 @@ int auths_delete(char *host)
...
@@ -502,6 +508,8 @@ int auths_delete(char *host)
}
}
out:
out:
free
(
json
);
json
=
NULL
;
free_registry_auths
(
auths
);
free_registry_auths
(
auths
);
auths
=
NULL
;
auths
=
NULL
;
free
(
err
);
free
(
err
);
...
...
src/image/oci/registry/registry.c
浏览文件 @
cd1a6685
...
@@ -132,6 +132,8 @@ static int parse_manifest_schema1(pull_descriptor *desc)
...
@@ -132,6 +132,8 @@ static int parse_manifest_schema1(pull_descriptor *desc)
desc
->
layers_len
=
manifest
->
fs_layers_len
;
desc
->
layers_len
=
manifest
->
fs_layers_len
;
out:
out:
free_image_manifest_v1_compatibility
(
v1config
);
v1config
=
NULL
;
free_registry_manifest_schema1
(
manifest
);
free_registry_manifest_schema1
(
manifest
);
manifest
=
NULL
;
manifest
=
NULL
;
free
(
err
);
free
(
err
);
...
@@ -185,10 +187,8 @@ static int parse_manifest_schema2(pull_descriptor *desc)
...
@@ -185,10 +187,8 @@ static int parse_manifest_schema2(pull_descriptor *desc)
desc
->
layers_len
=
manifest
->
layers_len
;
desc
->
layers_len
=
manifest
->
layers_len
;
out:
out:
if
(
manifest
!=
NULL
)
{
free_registry_manifest_schema2
(
manifest
);
free_registry_manifest_schema2
(
manifest
);
manifest
=
NULL
;
manifest
=
NULL
;
}
free
(
err
);
free
(
err
);
err
=
NULL
;
err
=
NULL
;
...
@@ -239,10 +239,8 @@ static int parse_manifest_ociv1(pull_descriptor *desc)
...
@@ -239,10 +239,8 @@ static int parse_manifest_ociv1(pull_descriptor *desc)
desc
->
layers_len
=
manifest
->
layers_len
;
desc
->
layers_len
=
manifest
->
layers_len
;
out:
out:
if
(
manifest
!=
NULL
)
{
free_oci_image_manifest
(
manifest
);
free_oci_image_manifest
(
manifest
);
manifest
=
NULL
;
manifest
=
NULL
;
}
free
(
err
);
free
(
err
);
err
=
NULL
;
err
=
NULL
;
...
@@ -941,10 +939,8 @@ static int parse_docker_config(pull_descriptor *desc)
...
@@ -941,10 +939,8 @@ static int parse_docker_config(pull_descriptor *desc)
out:
out:
if
(
config
!=
NULL
)
{
free_docker_image_config_v2
(
config
);
free_docker_image_config_v2
(
config
);
config
=
NULL
;
config
=
NULL
;
}
free
(
err
);
free
(
err
);
err
=
NULL
;
err
=
NULL
;
...
@@ -993,10 +989,8 @@ static int parse_oci_config(pull_descriptor *desc)
...
@@ -993,10 +989,8 @@ static int parse_oci_config(pull_descriptor *desc)
desc
->
config
.
create_time
=
created_to_timestamp
(
config
->
created
);
desc
->
config
.
create_time
=
created_to_timestamp
(
config
->
created
);
out:
out:
if
(
config
!=
NULL
)
{
free_oci_image_spec
(
config
);
free_oci_image_spec
(
config
);
config
=
NULL
;
config
=
NULL
;
}
free
(
err
);
free
(
err
);
err
=
NULL
;
err
=
NULL
;
...
@@ -1452,6 +1446,9 @@ static int add_rootfs_and_history(pull_descriptor *desc, docker_image_config_v2
...
@@ -1452,6 +1446,9 @@ static int add_rootfs_and_history(pull_descriptor *desc, docker_image_config_v2
config
->
history
[
i
]
=
history
;
config
->
history
[
i
]
=
history
;
config
->
history_len
++
;
config
->
history_len
++
;
free_docker_image_history
(
history
);
history
=
NULL
;
free_image_manifest_v1_compatibility
(
v1config
);
free_image_manifest_v1_compatibility
(
v1config
);
v1config
=
NULL
;
v1config
=
NULL
;
history_index
--
;
history_index
--
;
...
@@ -1471,6 +1468,8 @@ static int add_rootfs_and_history(pull_descriptor *desc, docker_image_config_v2
...
@@ -1471,6 +1468,8 @@ static int add_rootfs_and_history(pull_descriptor *desc, docker_image_config_v2
out:
out:
free
(
err
);
free
(
err
);
err
=
NULL
;
err
=
NULL
;
free_docker_image_history
(
history
);
history
=
NULL
;
free_image_manifest_v1_compatibility
(
v1config
);
free_image_manifest_v1_compatibility
(
v1config
);
v1config
=
NULL
;
v1config
=
NULL
;
...
@@ -1624,6 +1623,23 @@ out:
...
@@ -1624,6 +1623,23 @@ out:
return
ret
;
return
ret
;
}
}
static
void
update_host
(
pull_descriptor
*
desc
)
{
if
(
desc
==
NULL
)
{
ERROR
(
"Invalid NULL param"
);
return
;
}
// registry-1.docker.io is the real docker.io's registry. index.docker.io is V1 registry, we do not support
// V1 registry, try use registry-1.docker.io.
if
(
!
strcmp
(
desc
->
host
,
DOCKER_HOSTNAME
)
||
!
strcmp
(
desc
->
host
,
DOCKER_V1HOSTNAME
))
{
free
(
desc
->
host
);
desc
->
host
=
util_strdup_s
(
DOCKER_REGISTRY
);
}
return
;
}
static
int
prepare_pull_desc
(
pull_descriptor
*
desc
,
registry_pull_options
*
options
)
static
int
prepare_pull_desc
(
pull_descriptor
*
desc
,
registry_pull_options
*
options
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -1660,12 +1676,7 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio
...
@@ -1660,12 +1676,7 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio
goto
out
;
goto
out
;
}
}
// registry-1.docker.io is the real docker.io's registry. index.docker.io is V1 registry, we do not support
update_host
(
desc
);
// V1 registry, try use registry-1.docker.io.
if
(
!
strcmp
(
desc
->
host
,
DOCKER_HOSTNAME
)
||
!
strcmp
(
desc
->
host
,
DOCKER_V1HOSTNAME
))
{
free
(
desc
->
host
);
desc
->
host
=
util_strdup_s
(
DOCKER_REGISTRY
);
}
if
(
mkdtemp
(
blobpath
)
==
NULL
)
{
if
(
mkdtemp
(
blobpath
)
==
NULL
)
{
ERROR
(
"make temporary direcory failed: %s"
,
strerror
(
errno
));
ERROR
(
"make temporary direcory failed: %s"
,
strerror
(
errno
));
...
@@ -1850,6 +1861,7 @@ int registry_login(registry_login_options *options)
...
@@ -1850,6 +1861,7 @@ int registry_login(registry_login_options *options)
}
}
desc
->
host
=
util_strdup_s
(
options
->
host
);
desc
->
host
=
util_strdup_s
(
options
->
host
);
update_host
(
desc
);
desc
->
use_decrypted_key
=
conf_get_use_decrypted_key_flag
();
desc
->
use_decrypted_key
=
conf_get_use_decrypted_key_flag
();
desc
->
skip_tls_verify
=
options
->
skip_tls_verify
;
desc
->
skip_tls_verify
=
options
->
skip_tls_verify
;
desc
->
username
=
util_strdup_s
(
options
->
auth
.
username
);
desc
->
username
=
util_strdup_s
(
options
->
auth
.
username
);
...
...
src/image/oci/registry/registry_apiv2.c
浏览文件 @
cd1a6685
...
@@ -255,7 +255,7 @@ static int parse_ping_header(pull_descriptor *desc, char *http_head)
...
@@ -255,7 +255,7 @@ static int parse_ping_header(pull_descriptor *desc, char *http_head)
// {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
// {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
message
=
get_parsed_message
(
http_head
);
message
=
get_parsed_message
(
http_head
);
if
(
message
==
NULL
)
{
if
(
message
==
NULL
)
{
ERROR
(
"
out of memory"
);
ERROR
(
"
Get parsed message failed. http response size %zu, response:%s"
,
strlen
(
http_head
),
http_head
);
ret
=
-
1
;
ret
=
-
1
;
goto
out
;
goto
out
;
}
}
...
@@ -765,6 +765,8 @@ static int normalized_host_os_arch(char **host_os, char **host_arch, char **host
...
@@ -765,6 +765,8 @@ static int normalized_host_os_arch(char **host_os, char **host_arch, char **host
*
host_variant
=
util_strdup_s
(
"v7"
);
*
host_variant
=
util_strdup_s
(
"v7"
);
}
else
if
(
!
strcmp
(
tmp_variant
,
"8"
))
{
}
else
if
(
!
strcmp
(
tmp_variant
,
"8"
))
{
*
host_variant
=
util_strdup_s
(
"v8"
);
*
host_variant
=
util_strdup_s
(
"v8"
);
}
else
{
*
host_variant
=
util_strdup_s
(
tmp_variant
);
}
}
free
(
tmp_variant
);
free
(
tmp_variant
);
tmp_variant
=
NULL
;
tmp_variant
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录