From 5f74ab324e05f8cbd71394fb72ad703d628f2256 Mon Sep 17 00:00:00 2001 From: zengxs Date: Fri, 21 Dec 2018 14:08:56 +0800 Subject: [PATCH] fix: response truncated at the last character --- EasyHautX/Info.plist | 2 +- EasyHautX/httpclient.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EasyHautX/Info.plist b/EasyHautX/Info.plist index dd10fd7..9e19d3b 100644 --- a/EasyHautX/Info.plist +++ b/EasyHautX/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 0.1.0 CFBundleVersion - 1 + 2 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/EasyHautX/httpclient.cc b/EasyHautX/httpclient.cc index ea872c4..23825b0 100644 --- a/EasyHautX/httpclient.cc +++ b/EasyHautX/httpclient.cc @@ -93,7 +93,7 @@ size_t srun3k_login(const char *url, payload_t *payload, const char *key, char * return 0; } else { std::cout << readBuffer << std::endl; - size_t ret_size = sizeof(char) * readBuffer.length(); + size_t ret_size = sizeof(char) * (readBuffer.length() + 1); *response = (char *)malloc(ret_size); snprintf(*response, ret_size, "%s", readBuffer.c_str()); return ret_size; @@ -127,7 +127,7 @@ size_t srun3k_logout(const char *url, Payload payload, char **response) { if (res == CURLE_OK) { std::cout << readBuffer << std::endl; - size_t ret_size = sizeof(char) * readBuffer.length(); + size_t ret_size = sizeof(char) * (readBuffer.length() + 1); *response = (char *)malloc(ret_size); snprintf(*response, ret_size, "%s", readBuffer.c_str()); return ret_size;