diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index ac83adbda2..f29fb758ca 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,14 @@ namespace Core::System { +#ifndef HOST_NAME_MAX +# ifdef __APPLE__ +# define HOST_NAME_MAX 255 +# else +# define HOST_NAME_MAX 64 +# endif +#endif + #ifdef __serenity__ ErrorOr beep() @@ -336,7 +345,7 @@ ErrorOr ptsname(int fd) ErrorOr gethostname() { - char hostname[256]; + char hostname[HOST_NAME_MAX]; int rc = ::gethostname(hostname, sizeof(hostname)); if (rc < 0) return Error::from_syscall("gethostname"sv, -errno);