Hardcode magic number rather than rely on HOST_NAME_MAX

This commit is contained in:
Mathias Stearn
2010-07-23 18:04:13 -04:00
parent b56f9612f9
commit 5960b04407

View File

@@ -823,8 +823,9 @@ namespace mongo {
BSONObj getHostName(const BSONObj& a){
uassert( 13411, "getHostName accepts no arguments", a.nFields() == 0 );
char buf[HOST_NAME_MAX+1];
assert(gethostname(buf, HOST_NAME_MAX+1) == 0);
char buf[260]; // HOST_NAME_MAX is usually 255
assert(gethostname(buf, 260) == 0);
buf[259] = '\0';
return BSON("" << buf);
}