[PATCH] libnuma: fix obo error in set_thread_constraints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Neil Horman <nhorman@xxxxxxxxxxxxx>



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);
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux