mirror of
https://github.com/openbsd/src.git
synced 2025-12-06 07:58:21 +00:00
Ensure that we always return a null terminated string if the user
passed us a name buffer smaller than the thread name. ok deraadt@
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: rthread_np.c,v 1.25 2025/10/30 13:21:29 miod Exp $ */
|
/* $OpenBSD: rthread_np.c,v 1.26 2025/12/03 17:06:48 kurt Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
|
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
|
||||||
* Copyright (c) 2005 Otto Moerbeek <otto@openbsd.org>
|
* Copyright (c) 2005 Otto Moerbeek <otto@openbsd.org>
|
||||||
@@ -53,10 +53,13 @@ void
|
|||||||
pthread_get_name_np(pthread_t thread, char *name, size_t len)
|
pthread_get_name_np(pthread_t thread, char *name, size_t len)
|
||||||
{
|
{
|
||||||
pid_t tid = 0;
|
pid_t tid = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (thread != pthread_self())
|
if (thread != pthread_self())
|
||||||
tid = thread->tib->tib_tid;
|
tid = thread->tib->tib_tid;
|
||||||
getthrname(tid, name, len);
|
ret = getthrname(tid, name, len);
|
||||||
|
if (ret == ERANGE && len > 0)
|
||||||
|
name[len-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
Reference in New Issue
Block a user