diff --git a/ksmserver/client.cpp b/ksmserver/client.cpp index e6d6cb5d..46166e02 100644 --- a/ksmserver/client.cpp +++ b/ksmserver/client.cpp @@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include #include #include @@ -93,7 +94,8 @@ char * safeSmsGenerateClientID( SmsConn /*c*/ ) /* Faking our IP address, the 0 below is "unknown" address format (1 would be IP, 2 would be DEC-NET format) */ char hostname[ 256 ]; - if( gethostname( hostname, 255 ) != 0 ) + ::memset(hostname, '\0', sizeof(hostname)); + if( ::gethostname( hostname, 255 ) != 0 ) my_addr->sprintf("0%.8x", KRandom::random()); else { // create some kind of hash for the hostname diff --git a/ksmserver/legacy.cpp b/ksmserver/legacy.cpp index 1dbee4f4..fdcba9f9 100644 --- a/ksmserver/legacy.cpp +++ b/ksmserver/legacy.cpp @@ -33,6 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include #include "server.h" @@ -360,8 +361,8 @@ QString KSMServer::windowWmClientMachine(WId w) } else { // special name for the local machine (localhost) char hostnamebuf[80]; - if (gethostname (hostnamebuf, sizeof hostnamebuf) >= 0) { - hostnamebuf[sizeof(hostnamebuf)-1] = 0; + ::memset(hostnamebuf, '\0', sizeof(hostnamebuf)); + if (::gethostname (hostnamebuf, sizeof(hostnamebuf)) >= 0) { if (result == hostnamebuf) result = "localhost"; if(char *dot = strchr(hostnamebuf, '.')) { diff --git a/ksmserver/logouteffect.cpp b/ksmserver/logouteffect.cpp index 59be7c15..42a05c1f 100644 --- a/ksmserver/logouteffect.cpp +++ b/ksmserver/logouteffect.cpp @@ -29,7 +29,7 @@ #include "curtaineffect.h" #include // for gethostname() - +#include // for memset() static bool localDisplay(Display *dpy) { @@ -46,7 +46,8 @@ static bool localDisplay(Display *dpy) return true; char name[2048]; - gethostname(name, sizeof(name)); + ::memset(name, '\0', sizeof(name)); + ::gethostname(name, sizeof(name)); if (hostPart == name) return true;