protocol

protocol tests
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/protocol

commit 4e0738b5233f6651d964def1b1665a9265ef92ad
parent 3aefc2a8c50cad0b7235ac8022f2a5a16131e085
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 27 Mar 2017 00:27:37 +0200

Fix(resp_pkg): Add a forgotten strlen

Diffstat:
Msrc/client_test.c | 4++--
Msrc/package.c | 5+++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/client_test.c b/src/client_test.c @@ -46,7 +46,7 @@ SQL_CALLBACK_DEF(pkg_cb) { } } - char *tmp = pkg->dependencies, *token; + char *tmp = strdup(pkg->dependencies), *token; u16_t i = 0; while ((token = strtok_r(tmp, ", ", &tmp)) != NULL) i++; @@ -205,7 +205,7 @@ TEST(pkg_req_get_pkg_2_read) { pkg = pkgs->member; READ_TIMEOUT(sockfd, ret, 2048, 1, r_n); - ptr = pkg_build_resp_pkg(&size, pkg->id, pkg->sbu, pkg->inst_size, + ptr = pkg_build_resp_pkg(&size, pkg->id, pkg->sbu, pkg->inst_size, pkg->arch_size, pkg->state, pkg->name, pkg->category, pkg->version, pkg->description, pkg->archive, pkg->arch_hash, pkg->dependencies_arr_size, pkg->dependencies_arr); diff --git a/src/package.c b/src/package.c @@ -156,6 +156,7 @@ void *pkg_build_resp_pkg(size_t *size, u64_t id, float comp_time, pkg->description_len = strlen(description); pkg->checksum_len = strlen(checksum); pkg->dependencies_size = dep_size; + pkg->archive_len = strlen(archive); pkg->name = strdup(name); pkg->category = strdup(category); @@ -239,7 +240,7 @@ char *print_package(void *exp, void *ret, size_t exp_size, size_t ret_size) { res = strdup("\n "); for (size_t i = 0; i < exp_size; i++) { - asprintf(&res, "%s%02X ", res, (unsigned char)s_exp[i]); + asprintf(&res, "%s%02x ", res, (unsigned char)s_exp[i]); if ((i + 1) % 10 == 0 && i != 0) { for (size_t j = (i + 1) - 10; j < i + 1; j++) @@ -258,7 +259,7 @@ char *print_package(void *exp, void *ret, size_t exp_size, size_t ret_size) { if (i < max_size && s_ret[i] != s_exp[i]) asprintf(&res, "%s\033[0;31m%02x\033[0;37m ", res, (unsigned char)s_ret[i]); else - asprintf(&res, "%s%02X ", res, (unsigned char)s_ret[i]); + asprintf(&res, "%s%02x ", res, (unsigned char)s_ret[i]); if ((i + 1) % 10 == 0 && i != 0) { for (size_t j = (i + 1) - 10; j < i + 1; j++)