Skip to content

Commit 6465eb2

Browse files
committed
Move logging of hostname to /showip
This is an easily overlooked bit of potentially personally identifying information. It may be the "computer's name" on personal machines. So don't log it by default.
1 parent 2a46ed2 commit 6465eb2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/engine/qcommon/net_ip.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ struct nip_localaddr_t
170170
struct sockaddr_storage netmask;
171171
};
172172

173+
// Used to get local IP list. Saved here just to ensure /showip shows the same one that we used
174+
static char hostname[ 256 ];
173175
// Used for Sys_IsLANAddress
174176
static nip_localaddr_t localIP[ MAX_IPS ];
175177
static int numIP;
@@ -895,6 +897,8 @@ class ShowIPCommand : public Cmd::StaticCmd
895897

896898
void Run( const Cmd::Args & ) const override
897899
{
900+
Print( "Hostname: %s", hostname );
901+
898902
int i;
899903
char addrbuf[ NET_ADDR_STR_MAX_LEN ];
900904

@@ -1516,20 +1520,18 @@ static void NET_GetLocalAddress()
15161520
#else
15171521
static void NET_GetLocalAddress()
15181522
{
1519-
char hostname[ 256 ];
15201523
struct addrinfo hint;
15211524

15221525
struct addrinfo *res = nullptr;
15231526

15241527
numIP = 0;
15251528

1526-
if ( gethostname( hostname, 256 ) == SOCKET_ERROR )
1529+
if ( gethostname( hostname, sizeof( hostname ) ) == SOCKET_ERROR )
15271530
{
1531+
*hostname = '\0';
15281532
return;
15291533
}
15301534

1531-
Log::Notice( "Hostname: %s", hostname );
1532-
15331535
memset( &hint, 0, sizeof( hint ) );
15341536

15351537
hint.ai_family = AF_UNSPEC;

0 commit comments

Comments
 (0)