[Prevent] Fixed prevent issues
authorTaejeong Lee <taejeong.lee@samsung.com>
Mon, 14 Jan 2013 04:43:04 +0000 (13:43 +0900)
committerTaejeong Lee <taejeong.lee@samsung.com>
Mon, 14 Jan 2013 04:44:49 +0000 (13:44 +0900)
[Issue#]   prevent - #14493
[Bug]      Resource leak (RESOURCE_LEAK)
[Cause]    Bug.
[Solution] Release unhandled resource.

Change-Id: Ib52dcf3cb5aa2e8e4b5e241ce00e954e2bb7611e

src/wrt-launchpad-daemon/src/app_sock.c

index 0e74b93..44bb556 100644 (file)
@@ -82,6 +82,7 @@ int __create_server_sock(int pid)
                        /* or permission error by using 'emulator', bypass*/
                        if((errno != EOPNOTSUPP) && (errno != EPERM)) {
                                _E("labeling to socket(IPOUT) error");
+                close(fd);
                                return -1;
                        }
                }
@@ -90,6 +91,7 @@ int __create_server_sock(int pid)
                        /* or permission error by using 'emulator', bypass*/
                        if((errno != EOPNOTSUPP) && (errno != EPERM)) {
                                _E("labeling to socket(IPIN) error");
+                close(fd);
                                return -1;
                        }
                }
@@ -97,12 +99,14 @@ int __create_server_sock(int pid)
 
        if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
                _E("bind error");
+        close(fd);
                return -1;
        }
 
        if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
                /* Flawfinder: ignore*/
                _E("failed to change the socket permission");
+        close(fd);
                return -1;
        }