mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 00:39:52 +00:00
commit
fa1f593977
@ -61,36 +61,31 @@ namespace OHOS {
|
||||
|
||||
void OpenSessionSyncTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return;
|
||||
}
|
||||
char *charParam = const_cast<char *>(reinterpret_cast<const char *>(data));
|
||||
#define SESSION_NAME_SIZE_MAX 256
|
||||
#define DEVICE_ID_SIZE_MAX 65
|
||||
#define GROUP_ID_SIZE_MAX 65
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
char peerSessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
char peerNetworkId[DEVICE_ID_SIZE_MAX] = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00";
|
||||
if (data == nullptr || size >= GROUP_ID_SIZE_MAX) {
|
||||
return;
|
||||
}
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
char peerSessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
char peerNetworkId[DEVICE_ID_SIZE_MAX] = {0};
|
||||
char groupId[GROUP_ID_SIZE_MAX] = {0};
|
||||
SessionAttribute attr = {
|
||||
.dataType = TYPE_BYTES,
|
||||
};
|
||||
char groupId[GROUP_ID_SIZE_MAX] = "TEST_GROUP_ID";
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(peerSessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(peerSessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(peerNetworkId, DEVICE_ID_SIZE_MAX, charParam, DEVICE_ID_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(peerNetworkId, DEVICE_ID_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(groupId, GROUP_ID_SIZE_MAX, charParam, GROUP_ID_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(groupId, GROUP_ID_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
mySessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
peerSessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
peerNetworkId[DEVICE_ID_SIZE_MAX - 1] = '\0';
|
||||
groupId[GROUP_ID_SIZE_MAX - 1] = '\0';
|
||||
OpenSessionSync(mySessionName, peerSessionName, peerNetworkId, groupId, &attr);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -21,67 +21,56 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define SESSION_NAME_SIZE_MAX 256
|
||||
#define DEVICE_ID_SIZE_MAX 65
|
||||
#define GROUP_ID_SIZE_MAX 65
|
||||
|
||||
namespace OHOS {
|
||||
void CreateSessionServerInnerTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
if (data == nullptr || size < sizeof(int32_t) || size >= SESSION_NAME_SIZE_MAX) {
|
||||
return;
|
||||
}
|
||||
char *charParam = const_cast<char *>(reinterpret_cast<const char *>(data));
|
||||
#define SESSION_NAME_SIZE_MAX 256
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
mySessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
CreateSessionServerInner(nullptr, mySessionName);
|
||||
}
|
||||
|
||||
void RemoveSessionServerInnerTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
if (data == nullptr || size < sizeof(int32_t) || size >= SESSION_NAME_SIZE_MAX) {
|
||||
return;
|
||||
}
|
||||
char *charParam = const_cast<char *>(reinterpret_cast<const char *>(data));
|
||||
#define SESSION_NAME_SIZE_MAX 256
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
mySessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
RemoveSessionServerInner(nullptr, mySessionName);
|
||||
}
|
||||
|
||||
void OpenSessionInnerTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
if (data == nullptr || size < sizeof(int32_t) || size >= GROUP_ID_SIZE_MAX) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *charParam = const_cast<char *>(reinterpret_cast<const char *>(data));
|
||||
#define SESSION_NAME_SIZE_MAX 256
|
||||
#define DEVICE_ID_SIZE_MAX 65
|
||||
#define GROUP_ID_SIZE_MAX 65
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
char peerSessionName[SESSION_NAME_SIZE_MAX] = "ohos.fuzz.dms.test";
|
||||
char peerNetworkId[DEVICE_ID_SIZE_MAX] = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00";
|
||||
char groupId[GROUP_ID_SIZE_MAX] = "TEST_GROUP_ID";
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
char mySessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
char peerSessionName[SESSION_NAME_SIZE_MAX] = {0};
|
||||
char peerNetworkId[DEVICE_ID_SIZE_MAX] = {0};
|
||||
char groupId[GROUP_ID_SIZE_MAX] = {0};
|
||||
if (memcpy_s(mySessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(peerSessionName, SESSION_NAME_SIZE_MAX, charParam, SESSION_NAME_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(peerSessionName, SESSION_NAME_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(peerNetworkId, DEVICE_ID_SIZE_MAX, charParam, DEVICE_ID_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(peerNetworkId, DEVICE_ID_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(groupId, GROUP_ID_SIZE_MAX, charParam, GROUP_ID_SIZE_MAX - 1) != EOK) {
|
||||
if (memcpy_s(groupId, GROUP_ID_SIZE_MAX, data, size) != EOK) {
|
||||
return;
|
||||
}
|
||||
mySessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
peerSessionName[SESSION_NAME_SIZE_MAX - 1] = '\0';
|
||||
peerNetworkId[DEVICE_ID_SIZE_MAX - 1] = '\0';
|
||||
groupId[GROUP_ID_SIZE_MAX - 1] = '\0';
|
||||
OpenSessionInner(mySessionName, peerSessionName, peerNetworkId, groupId, size);
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ namespace OHOS {
|
||||
|
||||
void VtpCreateClientTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int)) {
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t streamType = *(reinterpret_cast<const int *>(data));
|
||||
int32_t streamType = *(reinterpret_cast<const int32_t *>(data));
|
||||
Communication::SoftBus::IpAndPort ipPort;
|
||||
std::pair<uint8_t*, uint32_t> sessionKey = std::make_pair(nullptr, 0);
|
||||
|
||||
@ -41,11 +41,11 @@ namespace OHOS {
|
||||
|
||||
void VtpCreateServerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int)) {
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t streamType = *(reinterpret_cast<const int *>(data));
|
||||
int32_t streamType = *(reinterpret_cast<const int32_t *>(data));
|
||||
Communication::SoftBus::IpAndPort ipPort;
|
||||
std::pair<uint8_t*, uint32_t> sessionKey = std::make_pair(nullptr, 0);
|
||||
|
||||
@ -67,18 +67,18 @@ namespace OHOS {
|
||||
}
|
||||
|
||||
Communication::SoftBus::IpAndPort ipPort;
|
||||
ipPort.ip = const_cast<char *>(reinterpret_cast<const char *>(data));
|
||||
ipPort.ip = {0};
|
||||
ipPort.port = *(reinterpret_cast<const int32_t *>(data));
|
||||
vtpStreamSocket.Connect(ipPort);
|
||||
}
|
||||
|
||||
void VtpSetOptionTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int)) {
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t type = *(reinterpret_cast<const int *>(data));
|
||||
int32_t type = *(reinterpret_cast<const int32_t *>(data));
|
||||
Communication::SoftBus::StreamAttr tmp;
|
||||
|
||||
vtpStreamSocket.SetOption(type, tmp);
|
||||
@ -86,11 +86,11 @@ namespace OHOS {
|
||||
|
||||
void VtpGetOptionTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < sizeof(int)) {
|
||||
if (data == nullptr || size < sizeof(int32_t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t type = *(reinterpret_cast<const int *>(data));
|
||||
int32_t type = *(reinterpret_cast<const int32_t *>(data));
|
||||
|
||||
vtpStreamSocket.GetOption(type);
|
||||
}
|
||||
@ -115,24 +115,28 @@ namespace OHOS {
|
||||
|
||||
void VtpEncrypt(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
if (data == nullptr || size < sizeof(size_t)) {
|
||||
return;
|
||||
}
|
||||
size_t inlen = *(reinterpret_cast<const size_t *>(data));
|
||||
size_t outlen = *(reinterpret_cast<const size_t *>(data));
|
||||
const void *in = reinterpret_cast<const void *>(data);
|
||||
void *out = const_cast<void *>(reinterpret_cast<const void *>(data));
|
||||
|
||||
vtpStreamSocket.Encrypt(in, size, out, size);
|
||||
vtpStreamSocket.Encrypt(in, inlen, out, outlen);
|
||||
}
|
||||
|
||||
void VtpDecrypt(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
if (data == nullptr || size < sizeof(size_t)) {
|
||||
return;
|
||||
}
|
||||
size_t inlen = *(reinterpret_cast<const size_t *>(data));
|
||||
size_t outlen = *(reinterpret_cast<const size_t *>(data));
|
||||
const void *in = reinterpret_cast<const void *>(data);
|
||||
void *out = const_cast<void *>(reinterpret_cast<const void *>(data));
|
||||
|
||||
vtpStreamSocket.Decrypt(in, size, out, size);
|
||||
vtpStreamSocket.Decrypt(in, inlen, out, outlen);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user