From 9c8b85c8096a112a96b873c50dd9c371c8c4b241 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 14 Aug 2024 22:10:29 +0200 Subject: [PATCH] removed ret from caller checks; fixed stopcrypto and startcrypto --- cmd/pcloudcc/control_tools.cpp | 6 +++--- lib/poverlay_linux/overlay_client.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/pcloudcc/control_tools.cpp b/cmd/pcloudcc/control_tools.cpp index 857223b..80c6cc1 100644 --- a/cmd/pcloudcc/control_tools.cpp +++ b/cmd/pcloudcc/control_tools.cpp @@ -62,7 +62,7 @@ int start_crypto(const char *pass) { size_t errm_size; int result = SendCall(STARTCRYPTO, pass, &ret, &errm, &errm_size); - if (result != 0 || ret != 0) { + if (result != 0) { std::cout << "Start Crypto failed. return is " << ret << " and message is " << (errm ? errm : "no message") << std::endl; } else { @@ -80,7 +80,7 @@ int stop_crypto() { size_t errm_size; int result = SendCall(STOPCRYPTO, "", &ret, &errm, &errm_size); - if (result != 0 || ret != 0) { + if (result != 0) { std::cout << "Stop Crypto failed. return is " << ret << " and message is " << (errm ? errm : "no message") << std::endl; } else { @@ -98,7 +98,7 @@ int finalize() { size_t errm_size; int result = SendCall(FINALIZE, "", &ret, &errm, &errm_size); - if (result != 0 || ret != 0) { + if (result != 0) { std::cout << "Finalize failed. return code is " << result << ", ret is " << ret << ", and message is " << (errm ? errm : "no message") << std::endl; diff --git a/lib/poverlay_linux/overlay_client.c b/lib/poverlay_linux/overlay_client.c index e7904ca..6c7fd0a 100644 --- a/lib/poverlay_linux/overlay_client.c +++ b/lib/poverlay_linux/overlay_client.c @@ -145,6 +145,8 @@ int SendCall(int id /*IN*/, const char *path /*IN*/, int *ret /*OUT*/, return -4; } + debug(D_NOTICE, "SendCall: Sending message type %d, path '%s'", id, path); + // prepare and send the message to the socket message *mes = (message *)sendbuf; memset(mes, 0, sendsize); @@ -171,6 +173,7 @@ int SendCall(int id /*IN*/, const char *path /*IN*/, int *ret /*OUT*/, } sendbytes += rc; } + debug(D_NOTICE, "SendCall: Sent %lu bytes", sendbytes); if (sendbytes != mes->length) { sprintf((char *)error_msg, @@ -221,6 +224,8 @@ int SendCall(int id /*IN*/, const char *path /*IN*/, int *ret /*OUT*/, } } + debug(D_NOTICE, "SendCall: Received %zu bytes", recvbytes); + if (!received_data) { *ret = 0; *out = strdup(""); @@ -234,6 +239,16 @@ int SendCall(int id /*IN*/, const char *path /*IN*/, int *ret /*OUT*/, result = 0; goto cleanup; } + + if (recvbytes >= sizeof(message)) { + message *rep = (message *)recvbuf; + debug(D_NOTICE, "SendCall: Received message type: %d, length: %lu", + rep->type, rep->length); + if (recvbytes >= rep->length) { + debug(D_NOTICE, "SendCall: Entire message content: '%s'", rep->value); + } + } + if (recvbytes < sizeof(message)) { debug(D_ERROR, "got incomplete message from socket"); *ret = -250;