From f4762a563c841a057026d720e50414b0e598ca88 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Tue, 8 Jan 2013 08:18:56 +0100 Subject: [PATCH] [Prevent] Fixing issues: 10639,10649,14493,23411,25147,27764,28120 [Issue#] LINUXNGWAP-651 [Bug] Resource leaks, error codes not checked [Cause] N/A [Solution] ree resources before exit [Verification] Build repository Change-Id: I080f0b69e4a43bbe3f26e356fad13fed0631eb29 --- src/view/common/view_logic_password_support.cpp | 2 +- src/wrt-launchpad-daemon/feature/preexec.h | 3 +++ src/wrt-launchpad-daemon/launchpad_src/launchpad.c | 2 +- src/wrt-launchpad-daemon/legacy/preload.h | 2 +- src/wrt-launchpad-daemon/src/app_sock.c | 5 +++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/view/common/view_logic_password_support.cpp b/src/view/common/view_logic_password_support.cpp index 8d079bd..1777fa2 100644 --- a/src/view/common/view_logic_password_support.cpp +++ b/src/view/common/view_logic_password_support.cpp @@ -231,7 +231,7 @@ DPL::Optional jsForAutoFillData(const char *uri) } std::string dataStr = data; - delete data; + delete[] data; // replace $VALUE, $KEY to data from database std::ostringstream jsOstring; jsOstring << dataStr; diff --git a/src/wrt-launchpad-daemon/feature/preexec.h b/src/wrt-launchpad-daemon/feature/preexec.h index 2cf64d0..d5e9907 100644 --- a/src/wrt-launchpad-daemon/feature/preexec.h +++ b/src/wrt-launchpad-daemon/feature/preexec.h @@ -92,6 +92,7 @@ static inline void __preexec_init(int argc, char **argv) if (type_t == NULL) { _E("no available memory\n"); __preexec_list_free(); + fclose(preexec_file); return; } @@ -116,6 +117,7 @@ static inline void __preexec_init(int argc, char **argv) _E("no available memory\n"); free(type_t); __preexec_list_free(); + fclose(preexec_file); return; } type_t->so_path = strdup(sopath); @@ -124,6 +126,7 @@ static inline void __preexec_init(int argc, char **argv) free(type_t->pkg_type); free(type_t); __preexec_list_free(); + fclose(preexec_file); return; } type_t->dl_do_pre_exe = func; diff --git a/src/wrt-launchpad-daemon/launchpad_src/launchpad.c b/src/wrt-launchpad-daemon/launchpad_src/launchpad.c index a8dd993..00631d4 100644 --- a/src/wrt-launchpad-daemon/launchpad_src/launchpad.c +++ b/src/wrt-launchpad-daemon/launchpad_src/launchpad.c @@ -316,7 +316,7 @@ _static_ void __add_history(int caller, int callee, const char *pkgname, free(kb_data); free(hd); } else { - hd = (struct history_data *)malloc(sizeof(char) * 1033); + hd = (struct history_data *)malloc(sizeof(struct history_data)); strncpy(hd->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1); strncpy(hd->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1); diff --git a/src/wrt-launchpad-daemon/legacy/preload.h b/src/wrt-launchpad-daemon/legacy/preload.h index c479447..1a3bdba 100644 --- a/src/wrt-launchpad-daemon/legacy/preload.h +++ b/src/wrt-launchpad-daemon/legacy/preload.h @@ -151,7 +151,7 @@ static inline void __preload_init_for_wrt() while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > (char*)0) { soname[strlen(soname) - 1] = 0; - handle = dlopen(soname, RTLD_NOW|RTLD_GLOBAL); + handle = dlopen((const char *)soname, RTLD_NOW|RTLD_GLOBAL); if (handle == NULL) continue; _D("preload %s# - handle : %x\n", soname, handle); diff --git a/src/wrt-launchpad-daemon/src/app_sock.c b/src/wrt-launchpad-daemon/src/app_sock.c index cc2328e..95fe640 100644 --- a/src/wrt-launchpad-daemon/src/app_sock.c +++ b/src/wrt-launchpad-daemon/src/app_sock.c @@ -52,7 +52,7 @@ int __create_server_sock(int pid) /* Create basedir for our sockets */ orig_mask = umask(0); - mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); + (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); umask(orig_mask); fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); @@ -110,6 +110,7 @@ int __create_server_sock(int pid) if (listen(fd, 10) == -1) { _E("listen error"); + close(fd); return -1; } @@ -224,7 +225,7 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t return (-1); /* select error: sockfd not set*/ done: - fcntl(fd, F_SETFL, flags); + (void) fcntl(fd, F_SETFL, flags); if (error) { close(fd); errno = error; -- 2.7.4