lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 24 Oct 2007 10:36:21 -0700
From:	Paul Jackson <pj@....com>
To:	Paul Menage <menage@...gle.com>
Cc:	Paul Jackson <pj@....com>, Adrian Bunk <bunk@...nel.org>,
	linux-kernel@...r.kernel.org
Subject: [RFC] cgroup simplify space stripping

From: Paul Jackson <pj@....com>

Simplify the space stripping code in cgroup file write.

Signed-off-by: Paul Jackson <pj@....com>

---

This patch applies after both:
	Adrian Bunk's: [2.6 patch] kernel/cgroup.c: remove dead code
	pj's: [PATCH] cgroup brace coding style fix

 kernel/cgroup.c |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

--- 2.6.23-mm1.orig/kernel/cgroup.c	2007-10-24 10:03:11.847801501 -0700
+++ 2.6.23-mm1/kernel/cgroup.c	2007-10-24 10:29:08.355032464 -0700
@@ -1327,6 +1327,7 @@ static ssize_t cgroup_common_file_write(
 		goto out1;
 	}
 	buffer[nbytes] = 0;	/* nul-terminate */
+	strstrip(buffer);	/* strip -just- trailing whitespace */
 
 	mutex_lock(&cgroup_mutex);
 
@@ -1347,19 +1348,9 @@ static ssize_t cgroup_common_file_write(
 			clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
 		break;
 	case FILE_RELEASE_AGENT:
-	{
-		struct cgroupfs_root *root = cgrp->root;
-		/* Strip trailing newline */
-		if (nbytes && (buffer[nbytes-1] == '\n'))
-			buffer[nbytes-1] = 0;
-		/* We never write anything other than '\0'
-		 * into the last char of release_agent_path,
-		 * so it always remains a NUL-terminated
-		 * string */
-		strncpy(root->release_agent_path, buffer, nbytes);
-		root->release_agent_path[nbytes] = 0;
+		BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
+		strcpy(cgrp->root->release_agent_path, buffer);
 		break;
-	}
 	default:
 		retval = -EINVAL;
 		goto out2;

-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj@....com> 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ