mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibC: Use ptsname_r() instead of ptsname() in openpty() (#7231)
This improves thread-safety because ptsname() is using a global buffer that is shared between threads.
This commit is contained in:
parent
812875bc89
commit
3ef6e31ded
Notes:
sideshowbarker
2024-07-18 17:53:19 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/3ef6e31ded5 Pull-request: https://github.com/SerenityOS/serenity/pull/7231
@ -34,8 +34,9 @@ int openpty(int* amaster, int* aslave, char* name, const struct termios* termp,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* tty_name = ptsname(*amaster);
|
||||
if (!tty_name) {
|
||||
char tty_name[32];
|
||||
int rc = ptsname_r(*amaster, tty_name, sizeof(tty_name));
|
||||
if (rc < 0) {
|
||||
int error = errno;
|
||||
close(*amaster);
|
||||
errno = error;
|
||||
|
Loading…
Reference in New Issue
Block a user