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:	Thu, 25 Feb 2010 12:24:07 +0200
From:	"Kirill A. Shutemov" <kirill@...temov.name>
To:	containers@...ts.linux-foundation.org,
	Li Zefan <lizf@...fujitsu.com>
Cc:	Paul Menage <menage@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	linux-kernel@...r.kernel.org,
	"Kirill A. Shutemov" <kirill@...temov.name>
Subject: [PATCH] cgroup: do not use dprintf in cgroup_event_listener

glibc's dprintf(3) is buggy:
http://sourceware.org/bugzilla/show_bug.cgi?id=11319

Let's not to use it in the example.

Signed-off-by: Kirill A. Shutemov <kirill@...temov.name>
---
 Documentation/cgroups/cgroup_event_listener.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/cgroups/cgroup_event_listener.c b/Documentation/cgroups/cgroup_event_listener.c
index 8c2d7aa..8c2bfc4 100644
--- a/Documentation/cgroups/cgroup_event_listener.c
+++ b/Documentation/cgroups/cgroup_event_listener.c
@@ -23,6 +23,7 @@ int main(int argc, char **argv)
 	int cfd = -1;
 	int event_control = -1;
 	char event_control_path[PATH_MAX];
+	char line[LINE_MAX];
 	int ret;
 
 	if (argc != 3) {
@@ -39,7 +40,7 @@ int main(int argc, char **argv)
 
 	ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
 			dirname(argv[1]));
-	if (ret > PATH_MAX) {
+	if (ret >= PATH_MAX) {
 		fputs("Path to cgroup.event_control is too long\n", stderr);
 		goto out;
 	}
@@ -57,7 +58,13 @@ int main(int argc, char **argv)
 		goto out;
 	}
 
-	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
+	ret = snprintf(line, LINE_MAX, "%d %d %s", efd, cfd, argv[2]);
+	if (ret >= LINE_MAX) {
+		fputs("Arguments string is too long\n", stderr);
+		goto out;
+	}
+
+	ret = write(event_control, line, strlen(line) + 1);
 	if (ret == -1) {
 		perror("Cannot write to cgroup.event_control");
 		goto out;
-- 
1.6.6.2

--
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