提交 a1ec31a7 编写于 作者: W WangFengTu 提交者: lifeng68

fix bug of base64 encode and add testcase for pull image

Signed-off-by: NWangFengTu <wangfengtu@huawei.com>
上级 54143137
......@@ -22,6 +22,7 @@ declare -a lines
# Root directory of integration tests.
INTEGRATION_ROOT=$(dirname "$(readlink -f "$BASH_SOURCE")")
LCR_ROOT_PATH="/var/lib/isulad/engines/lcr"
ISUALD_LOG="/var/lib/isulad/isulad.log"
function cut_output_lines() {
message=`$@ 2>&1`
......
#!/bin/bash
#
# attributes: isulad inheritance version
# concurrent: YES
# spend time: 1
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
# - iSulad licensed under the Mulan PSL v2.
# - You can use this software according to the terms and conditions of the Mulan PSL v2.
# - You may obtain a copy of Mulan PSL v2 at:
# - http://license.coscl.org.cn/MulanPSL2
# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# - PURPOSE.
# - See the Mulan PSL v2 for more details.
##- @Description:CI
##- @Author: wangfengtu
##- @Create: 2020-05-12
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ./helpers.bash
function isula_pull()
{
isula pull busybox
fn_check_eq "$?" "0" "isula pull busybox"
isula inspect busybox
fn_check_eq "$?" "0" "isula inspect busybox"
}
function do_test_t()
{
isula_pull
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
cat $ISUALD_LOG
let "ret=$ret + 1"
fi
show_result $ret "basic pull"
......@@ -31,6 +31,8 @@ size_t util_base64_encode(unsigned char *bytes, size_t len, char *out, size_t ou
int ret = 0;
int bio_ret = 0;
BUF_MEM *pmem = NULL;
size_t i = 0;
size_t count = 0;
if (bytes == NULL || len == 0 || out == NULL || out_len < util_base64_encode_len(len)) {
ERROR("Invalid param for encoding base64, input length %zu, out length %zu", len, out_len);
......@@ -66,16 +68,29 @@ size_t util_base64_encode(unsigned char *bytes, size_t len, char *out, size_t ou
}
(void)BIO_get_mem_ptr(io, &pmem);
if (pmem->length > out_len) {
ERROR("result length larger than output length, result length %zu, input length %zu, output length %zu",
pmem->length, len, out_len);
// BIO_write append '\n' if every 76 chars have be output, so we need to strip them.
for (i = 0; i < pmem->length; i++) {
if (pmem->data[i] == '\n') {
continue;
}
if (count + 1 == out_len) {
ERROR("result length larger than output length, result length %zu, input length %zu, output length %zu",
pmem->length, len, out_len);
ret = -1;
goto out;
}
out[count] = pmem->data[i];
count++;
}
if (count == 0) {
ERROR("Base64 encode failed, result count is zero");
ret = -1;
goto out;
}
(void)memcpy(out, pmem->data, pmem->length);
out[pmem->length - 1] = 0;
result_len = pmem->length;
out[count] = 0;
result_len = count + 1;
out:
......
......@@ -1192,7 +1192,7 @@ static int do_fetch(thread_fetch_info *info)
if (cache == NULL) {
ret = fetch_one_layer(info);
if (ret != 0) {
ERROR("failed to start thread to fetch layer %d", (int)info->index);
ERROR("failed to to fetch layer %d", (int)info->index);
goto out;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册