diff --git a/prebuilt/linux/hdc_std b/prebuilt/linux/hdc_std index 7875536a5f41f8cc45c193a9ce7dc252e20468c2..af74903012f70c8ca9ad33780740d58cba1aa7ca 100755 Binary files a/prebuilt/linux/hdc_std and b/prebuilt/linux/hdc_std differ diff --git a/prebuilt/windows/hdc_std.exe b/prebuilt/windows/hdc_std.exe index c9e57b643c84c91d31514c01fb1f813ebc45602c..a5c16dd5043faa4bc0a12e33e7991dd99f3c5b33 100644 --- a/prebuilt/windows/hdc_std.exe +++ b/prebuilt/windows/hdc_std.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:265578fba0335c3ada9f970ebcedbbcb77318dc44e2c4a7a5777ec5f9baff87f -size 2107392 +oid sha256:12a4a0401b280312bdc4dc9350a136d9431d1fdb70e2ab38d149b91b88aa81ee +size 2511872 diff --git a/src/common/async_cmd.cpp b/src/common/async_cmd.cpp index 2a9e9bc217b56cda331cea8ab2062f2593f5cceb..ed7949bad97867c5903bccd02d056a0faadb0e4b 100644 --- a/src/common/async_cmd.cpp +++ b/src/common/async_cmd.cpp @@ -108,6 +108,7 @@ bool AsyncCmd::Initial(uv_loop_t *loopIn, const CmdResultCallback callback, uint bool AsyncCmd::ExecuteCommand(const string &command) const { string cmd = command; + Base::Trim(cmd, "\""); if (options & OPTION_APPEND_NEWLINE) { cmd += "\n"; } diff --git a/src/common/async_cmd.h b/src/common/async_cmd.h index b319adf387f5d10c3eb23f153a0f26c877d8689f..a4c4341cf26612a41c3564259e70e8b6e936c78a 100644 --- a/src/common/async_cmd.h +++ b/src/common/async_cmd.h @@ -57,7 +57,7 @@ private: string cmdResult; bool running; bool hasStop = false; - uint32_t options; + uint32_t options = 0; uint8_t uvRef = 0; }; } // namespace Hdc diff --git a/src/common/auth.cpp b/src/common/auth.cpp index 6cbc76fe3dc1e12612bc027ec2e0af606b633640..b504aa9ca556cf1acd67c18a9f023bc158ff9d90 100644 --- a/src/common/auth.cpp +++ b/src/common/auth.cpp @@ -385,11 +385,13 @@ void ReadDaemonKeys(const char *file, list *listPublicKey) ret = Base::Base64DecodeBuf(reinterpret_cast(buf), strlen(buf), (uint8_t *)key); if (ret != sizeof(RSAPublicKey)) { WRITE_LOG(LOG_DEBUG, "%s: Invalid base64 data ret=%d", file, ret); + delete key; continue; } if (key->wordModulusSize != RSANUMWORDS) { WRITE_LOG(LOG_DEBUG, "%s: Invalid key len %d\n", file, key->wordModulusSize); + delete key; continue; } listPublicKey->push_back(key); diff --git a/src/common/base.cpp b/src/common/base.cpp index a8d4d6f0f65056505d46f114b569f94087e01400..d7e999e34ee55ab54678efe38226cbfcb3c49cd3 100644 --- a/src/common/base.cpp +++ b/src/common/base.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #ifdef __MUSL__ extern "C" { @@ -373,9 +374,11 @@ namespace Base { { srand(static_cast(GetRandom())); string ret = string(expectedLen, '0'); + std::stringstream val; for (auto i = 0; i < expectedLen; ++i) { - sprintf(&ret[i], "%X", rand() % BUF_SIZE_MICRO); + val << std::hex << (rand() % BUF_SIZE_MICRO); } + ret = val.str(); return ret; } @@ -561,7 +564,7 @@ namespace Base { #endif #else string sKey = key; - string sBuf = "getparam " + sKey; + string sBuf = "param get " + sKey; RunPipeComand(sBuf.c_str(), value, sizeOutBuf, true); #endif value[sizeOutBuf - 1] = '\0'; diff --git a/src/common/define_plus.h b/src/common/define_plus.h index b9af525088541c5774ff732d1d2b317cae12c462..d74797b65bde3a5d982b3f68be952a433f565c5c 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -282,7 +282,7 @@ struct HdcChannel { string connectKey; uv_tcp_t hWorkTCP; // work channel for client, forward channel for server uv_thread_t hWorkThread; - uint8_t uvRef; // libuv handle ref -- just main thread now + uint8_t uvRef = 0; // libuv handle ref -- just main thread now bool handshakeOK; bool isDead; bool serverOrClient; // client's channel/ server's channel diff --git a/src/common/serial_struct_define.h b/src/common/serial_struct_define.h index 9d5eae31d6b2ff91e30ee03633a768b4c9578de6..f2beb1cd82503cc308c000ba77035c679f7906fe 100644 --- a/src/common/serial_struct_define.h +++ b/src/common/serial_struct_define.h @@ -310,7 +310,7 @@ namespace SerialStruct { #if defined(HOST_MAC) static void WriteVarint(unsigned long value, Writer &out) { - WriteVarint((uint64_t)value, out); + WriteVarint(static_cast(value), out); } #endif @@ -350,7 +350,12 @@ namespace SerialStruct { #if defined(HOST_MAC) static bool ReadVarint(unsigned long &value, reader &in) { - return ReadVarint(value, in); + uint64_t intermediateValue; + if (ReadVarint(intermediateValue, in)) { + value = static_cast(intermediateValue); + return true; + } + return false; } #endif @@ -1257,7 +1262,7 @@ namespace SerialStruct { return false; } }; - template<> struct Serializer { + template<> struct Serializer { static void Serialize(uint32_t tag, uint16_t value, FlagsType<>, Writer &out, bool force = false) { Serializer::Serialize(tag, value, FlagsType(), out, force); diff --git a/src/common/session.cpp b/src/common/session.cpp index 256ec6cf8feb7bd36ad7f6724a8332123fcd6509..78f94ded4911d33da90cad901870372ff770ef88 100644 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -1059,5 +1059,4 @@ void HdcSessionBase::PostStopInstanceMessage(bool restart) WRITE_LOG(LOG_DEBUG, "StopDaemon has sended"); wantRestart = restart; } - } // namespace Hdc diff --git a/src/common/session.h b/src/common/session.h index cc03c65b588b640d9f3c66d51422f56e2f85d100..ce0b760c929d2ab03342ee3449ec01f9fa60261f 100644 --- a/src/common/session.h +++ b/src/common/session.h @@ -131,8 +131,9 @@ protected: ptrTask = new T(hTaskInfo); hTaskInfo->taskClass = ptrTask; hTaskInfo->taskType = taskType; - } else + } else { ptrTask = (T *)hTaskInfo->taskClass; + } if (!ptrTask->CommandDispatch(command, payload, payloadSize)) { ptrTask->TaskFinish(); } diff --git a/src/daemon/jdwp.cpp b/src/daemon/jdwp.cpp index 14b42e14f531bbb60aa6aaef24bf064263502d8c..84c58f780a1e0a5ec2228e6f8fa9e189f50c19ce 100644 --- a/src/daemon/jdwp.cpp +++ b/src/daemon/jdwp.cpp @@ -269,7 +269,7 @@ bool HdcJdwp::SendJdwpNewFD(uint32_t targetPID, int fd) // transfer fd to jvm // clang-format off if (Base::SendToStreamEx((uv_stream_t *)&ctx->pipe, (uint8_t *)&ctx->dummy, 1, (uv_stream_t *)&ctx->jvmTCP, - (void *)SendCallbackJdwpNewFD, (const void *)ctx) < 0) { + (void *)SendCallbackJdwpNewFD, (const void *)ctx) < 0) { break; } // clang-format on diff --git a/src/daemon/usb_ffs.h b/src/daemon/usb_ffs.h index a520560c91794d52a4116565cfffeafc246cbd6e..1998daaf582d55e5ce38f2b65cc14fd03a1702d8 100644 --- a/src/daemon/usb_ffs.h +++ b/src/daemon/usb_ffs.h @@ -199,20 +199,20 @@ static const struct { .config2Desc = config2, .config3Desc = config3, .wosHead = { - .interface = 1, - .dwLength = LONG_LE(sizeof(USB_FFS_DESC.wosHead) + sizeof(USB_FFS_DESC.wosDesc)), - .bcdVersion = SHORT_LE(1), - .wIndex = SHORT_LE(4), - .bCount = 1, - .Reserved = 0, - }, + .interface = 1, + .dwLength = LONG_LE(sizeof(USB_FFS_DESC.wosHead) + sizeof(USB_FFS_DESC.wosDesc)), + .bcdVersion = SHORT_LE(1), + .wIndex = SHORT_LE(4), + .bCount = 1, + .Reserved = 0, + }, .wosDesc = { - .bFirstInterfaceNumber = 0, - .Reserved1 = 1, - .CompatibleID = { 'W', 'I', 'N', 'U', 'S', 'B', '\0', '\0'}, - .SubCompatibleID = {0}, - .Reserved2 = {0}, - } + .bFirstInterfaceNumber = 0, + .Reserved1 = 1, + .CompatibleID = { 'W', 'I', 'N', 'U', 'S', 'B', '\0', '\0'}, + .SubCompatibleID = {0}, + .Reserved2 = {0}, + } }; } // namespace Hdc #endif diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index a364eb8e07b9955f0965bd323ccf4f4f7599deb6..40d095d0e2fd76a354ba9b1561cfb4cd4cc5609d 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -427,6 +427,13 @@ void LIBUSB_CALL HdcHostUSB::WriteUSBBulkCallback(struct libusb_transfer *transf USBHead *usbHead = reinterpret_cast(transfer->buffer); HSession hSession = reinterpret_cast(transfer->user_data); HdcSessionBase *server = reinterpret_cast(hSession->classInstance); + uint16_t zeroMask = hSession->hUSB->wMaxPacketSize - 1; + if (transfer->length != 0 && zeroMask != 0 && (transfer->length & zeroMask) == 0) { + transfer->length = 0; + if (libusb_submit_transfer(transfer) == 0) { + return; + } + } if (usbHead->option & USB_OPTION_TAIL) { --hSession->sendRef; } diff --git a/src/host/server.cpp b/src/host/server.cpp index acc505ad97e5d7ae0a6c1daac3377ce639b2cedd..faf9834f27f0886e7be9123912cc385b21cebfcf 100644 --- a/src/host/server.cpp +++ b/src/host/server.cpp @@ -767,5 +767,4 @@ bool HdcServer::RemoveInstanceTask(const uint8_t op, HTaskInfo hTask) } return ret; } - } // namespace Hdc \ No newline at end of file diff --git a/src/test/main.cpp b/src/test/main.cpp index 873fe0a83b9de72dafa23a6450b8623fe4ff2a6d..46f9fbda509c5dff09aef6e97318ab1e40dfe278 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -16,7 +16,6 @@ using namespace Hdc; namespace HdcTest { - TEST(HdcBaseFunction, HandleNoneZeroInput) { char bufString[256] = ""; @@ -69,7 +68,6 @@ TEST(AppCommand, HandleNoneZeroInput) GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_APP)); delete ftest; } - } // namespace HdcTest int main(int argc, const char *argv[]) diff --git a/src/test/ut_mod.cpp b/src/test/ut_mod.cpp index 0da1cbfd5407590e36b6cb84e8ab75e5b0d84e6e..8e3e4a92f6737987579463bf60fb3b9180ce32b3 100644 --- a/src/test/ut_mod.cpp +++ b/src/test/ut_mod.cpp @@ -284,5 +284,4 @@ bool TestAppCommand(void *runtimePtr) } return true; } - } // namespace HdcTest \ No newline at end of file diff --git a/src/test/ut_runtime.cpp b/src/test/ut_runtime.cpp index 48708c642fb3edf00ecd571c251effd7d51d7ac2..6cd8f1f4134ff007c9d237c24b55b2f0ab67dcba 100644 --- a/src/test/ut_runtime.cpp +++ b/src/test/ut_runtime.cpp @@ -225,5 +225,4 @@ void Runtime::WorkerPendding() uv_run(&loopMain, UV_RUN_DEFAULT); WRITE_LOG(LOG_DEBUG, "TesPendding free"); } - } // namespace HdcTest \ No newline at end of file