pidgin: 280dc76b: me likes this better, References #5565
khc at pidgin.im
khc at pidgin.im
Fri Nov 28 20:55:28 EST 2008
-----------------------------------------------------------------
Revision: 280dc76b99f56c1c9e8c8c8175e03b356f27f757
Ancestor: 814dba6bc690168debf2736ede5e3f17dffa65ee
Author: khc at pidgin.im
Date: 2008-11-29T01:52:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/280dc76b99f56c1c9e8c8c8175e03b356f27f757
Modified files:
libpurple/protocols/jabber/jabber.c
ChangeLog:
me likes this better, References #5565
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 2f95ffd441d330e3c9955c901d2782ab4b532cb3
+++ libpurple/protocols/jabber/jabber.c 0bcffc1ebedf9cb4d1a0cbf55c98323f03c0a7cf
@@ -150,14 +150,21 @@ static char *jabber_prep_resource(char *
char hostname[256]; /* current hostname */
/* Empty resource == don't send any */
- if (strlen(input) == 0)
+ if (*input == '\0' || strstr(input, "__HOSTNAME__") == NULL)
return NULL;
/* Replace __HOSTNAME__ with hostname */
- if (gethostname(hostname, sizeof(hostname))) {
- purple_debug_warning("jabber", "gethostname() failed -- is your hostname set?");
+ if (gethostname(hostname, sizeof(hostname) - 1)) {
+ purple_debug_warning("jabber", "gethostname: %s\n", g_strerror(errno));
+ /* according to glibc doc, the only time an error is returned
+ is if the hostname is longer than the buffer, in which case
+ glibc 2.2+ would still fill the buffer with partial
+ hostname, so maybe we want to detect that and use it
+ instead
+ */
strcpy(hostname, "localhost");
}
+ hostname[sizeof(hostname) - 1] = '\0';
return purple_strreplace(input, "__HOSTNAME__", hostname);
}
More information about the Commits
mailing list