Blame SOURCES/libcgroup-0.40.rc1-coverity.patch

705669
diff -up libcgroup-0.41/src/api.c.coverity libcgroup-0.41/src/api.c
705669
--- libcgroup-0.41/src/api.c.coverity	2014-01-13 20:52:49.853838149 +0100
705669
+++ libcgroup-0.41/src/api.c	2014-01-13 20:52:49.854838142 +0100
705669
@@ -2791,7 +2791,6 @@ static int cgroup_create_template_group(
da3e87
 	if (group_name == NULL) {
da3e87
 		ret = ECGOTHER;
da3e87
 		last_errno = errno;
da3e87
-		free(template_name);
da3e87
 		goto end;
da3e87
 	}
da3e87
 
705669
diff -up libcgroup-0.41/src/config.c.coverity libcgroup-0.41/src/config.c
705669
--- libcgroup-0.41/src/config.c.coverity	2014-01-13 15:05:56.000000000 +0100
705669
+++ libcgroup-0.41/src/config.c	2014-01-13 20:52:49.854838142 +0100
705669
@@ -323,7 +323,7 @@ int config_group_task_perm(char *perm_ty
da3e87
 	long val = atoi(value);
da3e87
 	char buffer[CGROUP_BUFFER_LEN];
da3e87
 	struct cgroup *config_cgroup;
da3e87
-	int table_index;
da3e87
+	int table_index, ret;
da3e87
 
da3e87
 	switch (flag) {
da3e87
 	case CGROUP:
705669
@@ -367,10 +367,10 @@ int config_group_task_perm(char *perm_ty
da3e87
 			if (!group)
da3e87
 				goto group_task_error;
da3e87
 
da3e87
-			getgrnam_r(value, group, buffer,
da3e87
+			ret = getgrnam_r(value, group, buffer,
da3e87
 					CGROUP_BUFFER_LEN, &group_buffer);
da3e87
 
da3e87
-			if (group_buffer == NULL) {
da3e87
+			if (ret != 0 || group_buffer == NULL) {
da3e87
 				free(group);
da3e87
 				goto group_task_error;
da3e87
 			}
705669
@@ -436,7 +436,7 @@ int config_group_admin_perm(char *perm_t
da3e87
 	struct cgroup *config_cgroup;
da3e87
 	long val = atoi(value);
da3e87
 	char buffer[CGROUP_BUFFER_LEN];
da3e87
-	int table_index;
da3e87
+	int table_index, ret;
da3e87
 
da3e87
 	switch (flag) {
da3e87
 	case CGROUP:
705669
@@ -479,10 +479,10 @@ int config_group_admin_perm(char *perm_t
da3e87
 			if (!group)
da3e87
 				goto admin_error;
da3e87
 
da3e87
-			getgrnam_r(value, group, buffer,
da3e87
+			ret = getgrnam_r(value, group, buffer,
da3e87
 					CGROUP_BUFFER_LEN, &group_buffer);
da3e87
 
da3e87
-			if (group_buffer == NULL) {
da3e87
+			if (ret != 0 || group_buffer == NULL) {
da3e87
 				free(group);
da3e87
 				goto admin_error;
da3e87
 			}
705669
diff -up libcgroup-0.41/src/daemon/cgrulesengd.c.coverity libcgroup-0.41/src/daemon/cgrulesengd.c
705669
--- libcgroup-0.41/src/daemon/cgrulesengd.c.coverity	2014-01-13 15:05:56.000000000 +0100
705669
+++ libcgroup-0.41/src/daemon/cgrulesengd.c	2014-01-13 20:52:49.854838142 +0100
da3e87
@@ -646,7 +646,7 @@ close:
da3e87
 
da3e87
 static int cgre_create_netlink_socket_process_msg(void)
da3e87
 {
da3e87
-	int sk_nl = 0, sk_unix = 0, sk_max;
da3e87
+	int sk_nl = -1, sk_unix = -1, sk_max;
da3e87
 	struct sockaddr_nl my_nla;
da3e87
 	char buff[BUFF_SIZE];
da3e87
 	int rc = -1;
da3e87
@@ -784,9 +784,9 @@ static int cgre_create_netlink_socket_pr
da3e87
 	}
da3e87
 
da3e87
 close_and_exit:
da3e87
-	if (sk_nl > 0)
da3e87
+	if (sk_nl > -1)
da3e87
 		close(sk_nl);
da3e87
-	if (sk_unix > 0)
da3e87
+	if (sk_unix > -1)
da3e87
 		close(sk_unix);
da3e87
 	return rc;
da3e87
 }
705669
diff -upr libcgroup-0.40.rc1.orig/src/tools/lscgroup.c libcgroup-0.40.rc1/src/tools/lscgroup.c
705669
--- libcgroup-0.40.rc1.orig/src/tools/lscgroup.c	2013-05-21 15:36:04.000000000 +0200
705669
+++ libcgroup-0.40.rc1/src/tools/lscgroup.c	2013-11-04 14:26:53.400473523 +0100
705669
@@ -97,11 +97,11 @@ static int display_controller_data(char
705669
 	if (ret != 0)
705669
 		return ret;
705669
 
705669
-	strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX);
705669
+	strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX - 1);
705669
 	/* remove problematic  '/' characters from cgroup directory path*/
705669
 	trim_filepath(cgroup_dir_path);
705669
 
705669
-	strncpy(input_dir_path, input_path, FILENAME_MAX);
705669
+	strncpy(input_dir_path, input_path, FILENAME_MAX - 1);
705669
 
705669
 	/* remove problematic  '/' characters from input directory path*/
705669
 	trim_filepath(input_dir_path);