diff options
author | Ethan Blanton <elb@pidgin.im> | 2007-09-03 23:15:11 +0000 |
---|---|---|
committer | Ethan Blanton <elb@pidgin.im> | 2007-09-03 23:15:11 +0000 |
commit | fbbb1350d7f210ec52c06c2b1e020c25a00d9958 (patch) | |
tree | 569f2f2aa2f6c1abc60279c0f2a7f73217b1a2a0 /libpurple/protocols/irc/irc.c | |
parent | 60a36df0a3f151f19c101af65801179277d38212 (diff) | |
download | pidgin-fbbb1350d7f210ec52c06c2b1e020c25a00d9958.tar.gz |
Handle the case where gethostname() fails or returns a null hostname.
This really shouldn't happen on a properly configured system, but its
failure also should not prevent us from being able to log into IRC.
Fixes #2932
Diffstat (limited to 'libpurple/protocols/irc/irc.c')
-rw-r--r-- | libpurple/protocols/irc/irc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c index a783ae0fbc..731f38c53d 100644 --- a/libpurple/protocols/irc/irc.c +++ b/libpurple/protocols/irc/irc.c @@ -347,6 +347,7 @@ static gboolean do_login(PurpleConnection *gc) { const char *username, *realname; struct irc_conn *irc = gc->proto_data; const char *pass = purple_connection_get_password(gc); + int ret; if (pass && *pass) { buf = irc_format(irc, "vv", "PASS", pass); @@ -359,8 +360,12 @@ static gboolean do_login(PurpleConnection *gc) { } - gethostname(hostname, sizeof(hostname)); + ret = gethostname(hostname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = '\0'; + if (ret < 0 || hostname[0] == '\0') { + purple_debug_warning("irc", "gethostname() failed -- is your hostname set?"); + strcpy(hostname, "localhost"); + } realname = purple_account_get_string(irc->account, "realname", ""); username = purple_account_get_string(irc->account, "username", ""); |