about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-12-21 19:26:29 -0500
committerUlrich Drepper <drepper@gmail.com>2011-12-21 19:26:29 -0500
commit60e8585f2a2aa288a403a581f1dc8d3fc373598b (patch)
treeeadde2f50d58d87d551978db011b25f14bb7beff /nptl
parent8fa26d571d4b87a1c7a7f19f1365f7e5d2995933 (diff)
downloadglibc-60e8585f2a2aa288a403a581f1dc8d3fc373598b.tar.gz
glibc-60e8585f2a2aa288a403a581f1dc8d3fc373598b.tar.xz
glibc-60e8585f2a2aa288a403a581f1dc8d3fc373598b.zip
Fix reading thread name from comm file
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_getname.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index b622fe7c0f..31177bf17c 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-21  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #13515]
+	* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
+	Correct reading name from file.
+
 2011-12-14  Carlos O'Donell  <carlos@systemhalted.org>
 
 	* allocatestack.c (allocate_stack): Return errno on failure.
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_getname.c b/nptl/sysdeps/unix/sysv/linux/pthread_getname.c
index 6e7786f987..2c5ee6305e 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_getname.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_getname.c
@@ -1,5 +1,5 @@
 /* pthread_getname_np -- Get  thread name.  Linux version
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -57,6 +57,15 @@ pthread_getname_np (th, buf, len)
   ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, len));
   if (n < 0)
     res = errno;
+  else
+    {
+      if (buf[n - 1] == '\n')
+	buf[n - 1] = '\0';
+      else if (n == len)
+	res = ERANGE;
+      else
+	buf[n] = '\0';
+    }
 
   close_not_cancel_no_status (fd);