Date:	Mon, 10 Aug 2009 07:12:19 -0400
From:	Neil Horman <nhorman@tuxdriver.com>
To:	linux-numa@vger.kernel.org
Subject: [PATCH] libnuma: fix obo error in set_thread_constraints

[ this was never applied, as it was replaced by patch 1006_jb_strlen ]

Hey all-
	Patch to fix an obo error in set_thread_constraints.  nodes_alowed_list
gets allocated to be exactly the length needed, But since theres a newline in
the buffer array, we only copy 2 bytes, and fail to copy the the last character,
so we fail to terminate the string in nodes_allowed_list.  As such we can't use
strlen on nodes_allowed_list safely. Instead compute the end of the string using
buffer.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

diff -up numactl-2.0.3/libnuma.c.orig numactl-2.0.3/libnuma.c
--- numactl-2.0.3/libnuma.c.orig	2009-08-10 07:02:12.000000000 -0400
+++ numactl-2.0.3/libnuma.c	2009-08-10 07:02:39.000000000 -0400
@@ -464,7 +464,7 @@ set_thread_constraints(void)
 			nodes_allowed_list = malloc(strlen(buffer)-18);
 			strncpy(nodes_allowed_list, buffer + 19,
 				strlen(buffer) - 19);
-			nodes_allowed_list[strlen(nodes_allowed_list)-1] = '\0';
+			nodes_allowed_list[strlen(buffer)-19] = '\0';
 		}
 	}
 	fclose(f);
