oaf gethostby* bug
- From: Dan Winship <danw helixcode com>
- To: gnome-components-list gnome org
- Subject: oaf gethostby* bug
- Date: Wed, 13 Sep 2000 15:59:02 -0400 (EDT)
oaf_hostname_get assumes it can pass the result of gethostbyname as an
argument to gethostbyaddr, which is not safe, since they might be
using the same static buffer. Mmmm... static data.
Index: liboaf/oaf-mainloop.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-mainloop.c,v
retrieving revision 1.23
diff -u -r1.23 oaf-mainloop.c
--- liboaf/oaf-mainloop.c 2000/08/11 23:15:57 1.23
+++ liboaf/oaf-mainloop.c 2000/09/13 19:51:33
@@ -119,23 +119,24 @@
oaf_hostname_get (void)
{
static char *hostname = NULL;
- char hn_tmp[65];
- struct hostent *hent, *hent2;
+ char hn_tmp[65], ha_tmp[4];
+ struct hostent *hent;
if (!hostname) {
gethostname (hn_tmp, sizeof (hn_tmp) - 1);
hent = gethostbyname (hn_tmp);
if (hent) {
- hent2 = gethostbyaddr (hent->h_addr, 4, AF_INET);
- if (hent2)
- hostname = g_strdup (hent2->h_name);
+ memcpy (ha_tmp, hent->h_addr, 4);
+ hent = gethostbyaddr (ha_tmp, 4, AF_INET);
+ if (hent)
+ hostname = g_strdup (hent->h_name);
else
hostname =
g_strdup (inet_ntoa
(*
((struct in_addr *)
- hent->h_addr)));
+ ha_tmp)));
} else
hostname = g_strdup (hn_tmp);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]