+Fri Aug 24 8:54:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * net.cc (free_addr_list): Add define for symmetry.
+ (free_hostent_ptr): Use free_addr_list to free h_addr_list element.
+
+Thu Aug 23 16:00:09 2001 Jason Tishler <jason@tishler.net>
+
+ * net.cc (dup_addr_list): New static function.
+ (dup_hostent_ptr): Use dup_addr_list instead of dup_char_list in order
+ to handle embedded null characters.
+
Wed Aug 22 22:23:14 2001 Christopher Faylor <cgf@cygnus.com>
* dtable.cc (dtable::dup2): Allow extension of fd table by dup2.
return dst;
}
+#define free_addr_list(addr_list) free_char_list (addr_list)
+
+static char **
+dup_addr_list (char **src, unsigned int size)
+{
+ char **dst;
+ int cnt = 0;
+
+ for (char **cl = src; *cl; ++cl)
+ ++cnt;
+ if (!(dst = (char **) calloc (cnt + 1, sizeof *dst)))
+ return NULL;
+ while (cnt-- > 0)
+ {
+ if (!(dst[cnt] = (char *) malloc(size)))
+ return NULL;
+ memcpy(dst[cnt], src[cnt], size);
+ }
+ return dst;
+}
+
static void
free_protoent_ptr (struct protoent *&p)
{
if (p->h_name)
free ((void *)p->h_name);
free_char_list (p->h_aliases);
- free_char_list (p->h_addr_list);
+ free_addr_list (p->h_addr_list);
p = NULL;
}
}
goto out;
if (src->h_aliases && !(dst->h_aliases = dup_char_list (src->h_aliases)))
goto out;
- if (src->h_addr_list && !(dst->h_addr_list = dup_char_list(src->h_addr_list)))
+ if (src->h_addr_list
+ && !(dst->h_addr_list = dup_addr_list(src->h_addr_list, src->h_length)))
goto out;
debug_printf ("hostent: copied %s", dst->h_name);