Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os,report: use UV_MAXHOSTNAMESIZE #26038

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,9 @@

#ifdef __POSIX__
# include <limits.h> // PATH_MAX on Solaris.
# include <netdb.h> // MAXHOSTNAMELEN on Solaris.
# include <unistd.h> // gethostname, sysconf
# include <sys/param.h> // MAXHOSTNAMELEN on Linux and the BSDs.
#endif // __POSIX__

// Add Windows fallback.
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
#endif // MAXHOSTNAMELEN

namespace node {
namespace os {

Expand All @@ -66,7 +59,7 @@ using v8::Value;

static void GetHostname(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
char buf[MAXHOSTNAMELEN + 1];
char buf[UV_MAXHOSTNAMESIZE];
size_t size = sizeof(buf);
int r = uv_os_gethostname(buf, &size);

Expand Down
11 changes: 1 addition & 10 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@
extern char** environ;
#endif

#ifdef __POSIX__
# include <netdb.h> // MAXHOSTNAMELEN on Solaris.
# include <sys/param.h> // MAXHOSTNAMELEN on Linux and the BSDs.
#endif // __POSIX__

#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
#endif // MAXHOSTNAMELEN

namespace report {
using node::arraysize;
using node::Environment;
Expand Down Expand Up @@ -377,7 +368,7 @@ static void PrintVersionInformation(JSONWriter* writer) {
writer->json_keyvalue("osMachine", os_info.machine);
}

char host[MAXHOSTNAMELEN + 1];
char host[UV_MAXHOSTNAMESIZE];
size_t host_size = sizeof(host);

if (uv_os_gethostname(host, &host_size) == 0)
Expand Down