# HG changeset patch # User Mark Doliner # Date 1201498288 0 # Node ID 6337a8fd7784c62191e6986d42eb7ed612637fc3 # Parent da9179374c500d179c69cd88f91f06d628cc1d3b From the gethostname() man page: "In case the null-terminated hostname does not fit, no error is returned, but the hostname is truncated. It is unspecified whether the truncated hostname will be null-terminated." diff -r da9179374c50 -r 6337a8fd7784 libpurple/protocols/bonjour/bonjour.c --- a/libpurple/protocols/bonjour/bonjour.c Mon Jan 28 04:10:59 2008 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Mon Jan 28 05:31:28 2008 +0000 @@ -673,11 +673,12 @@ /* Try to figure out a good host name to use */ /* TODO: Avoid 'localhost,' if possible */ - if (gethostname(hostname, 255) != 0) { + if (gethostname(hostname, sizeof(hostname)) != 0) { purple_debug_warning("bonjour", "Error when getting host name: %s. Using \"localhost.\"\n", g_strerror(errno)); strcpy(hostname, "localhost"); } + hostname[sizeof(hostname) - 1] = '\0'; default_hostname = g_strdup(hostname); }