static void* push_pkgs_thread(void* args)
{
- char* pkg_data = strdup((char*)args);
+ char* pkg_data = (char*)args;
char* data = strdup(pkg_data);
if (pkg_data == NULL || data == NULL) {
LOG_SEVERE("pkg data strdup is failed.\n");
static void do_package(char* cat, type_action action, const char* data)
{
+ if (data == NULL || strlen(data) <= 0) {
+ LOG_SEVERE("data is corrupted.\n");
+ return;
+ }
+
if (action == 1) {
LOG_INFO("[pkgs] Already installed: %s\n", data);
} else if (action == 2) {
LOG_INFO("[pkgs] Needed to install: %s\n", data);
- char pkgs[MAX_PKGS_LIST];
- strcpy(pkgs, data);
+ char* pkgs = g_malloc0(MAX_PKGS_LIST);
+ strncpy(pkgs, data, MAX_PKGS_LIST - 1);
qemu_thread_create(&sdb_thread_id, "sdb_push", push_pkgs_thread, (void*)pkgs, QEMU_THREAD_DETACHED);
} else if (action == 3) {
LOG_INFO("[pkgs] Package Installation Success: %s\n", data);
} else if (!strcmp(cat, MSG_TYPE_PACKAGE)) {
do_package(cat, action, data);
return true;
+ } else if (!strcmp(cat, MSG_TYPE_GUESTIP)) {
+ if (data != NULL && strlen(data) > 0) {
+ LOG_INFO("guest ip: %s\n", data);
+ set_emul_guest_ip((char*)data);
+ } else {
+ LOG_SEVERE("guest ip is null!\n");
+ }
+ return true;
}
-
return false;
}
}
TRACE("<< header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
- if (!strcmp(cat, MSG_TYPE_GUESTIP)) {
- if (length > 0) {
- INFO("guest ip: %s\n", (char*)ijdata);
- set_emul_guest_ip((char*)ijdata);
- return true;
- } else {
- ERR("guest ip is null!\n");
- return false;
- }
- }
+
ECS__Master master = ECS__MASTER__INIT;
ECS__InjectorNtf ntf = ECS__INJECTOR_NTF__INIT;