Date: Thu, 13 Sep 2001 00:34:06 -0400 (EDT) From: Joe Clarke <marcus@marcuscom.com> To: Jordan Hubbard <jkh@freebsd.org> Cc: <so@i-clue.de>, <stable@freebsd.org> Subject: Re: Netatalk crash on RC4 (was: Re: 4.4-RC4 report [succes]) Message-ID: <20010913003010.Y411-200000@shumai.marcuscom.com> In-Reply-To: <20010912171443G.jkh@freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Jordan, here is another patch which replaces the two I sent earlier. This
should fix not only the core dump problems, but the realloc/free warnings
as well. This code only gets called when no atalkd.conf file exists. If
you or Christoph could test this code, and let me know if it works, I will
add it to the port. I've tested things here, and it works for me,
and passes the A and Z malloc tests. Thanks.
Joe
On Wed, 12 Sep 2001, Jordan Hubbard wrote:
> Progress! For the record, here's what I was getting on a RELENG_4 box
> (as of this morning) when netatalk attempted to start up from
> /usr/local/etc/rc.d/netatalk.sh:
>
> katalkd in realloc(): warning: chunk is already free.
> atalkd in free(): warning: chunk is already free.
> AppleTalk not up! Check your syslog for the reason. Child died.
> Sep 12 16:56:44 freebsd /kernel: pid 280 (atalkd), uid 0: exited on signal 11 (core dumped)
> Sep 12 16:56:44 freebsd atalkd: difaddr(0.0): Can't assign requested address
> nbp_rgstr: Network is unreachable
> Can't register freebsd:netatalk@*
> nbp_rgstr: Network is unreachable
> Can't register freebsd:Workstation@*
> Sep 12 16:56:45 freebsd afpd[286]: Can't register freebsd:AFPServer@*
>
> I then checked /usr/local/etc/atalkd.conf and saw that it was all
> simply commented out examples. I have only one interface, rl0, and
> according to the comments it should have been auto-discovered, but just
> on a lark I tried adding it to atalkd.conf to see if it had any
> effect. It did! All the core dumps have gone away.
>
> Now I'm on to my second problem. I've put /usr (just that, on a line
> by itself) into /usr/local/etc/AppleVolumes.default and "usr" (but
> with no leading slash) shows up in the volumes menu when I go to mount
> it over AFP under MacOS X. If I then select this, the server disconnects
> immediately and I get:
>
> afpd[pid]: dsi_stream_read(0): No such file or directory
>
> On the FreeBSD machine's console. Could it be because it's exporting
> "usr" vs "/usr"? If so, why would it do that when I used "/usr" in
> the AppleVolumes.default file?
>
> Thanks for all your help so far.
>
> - Jordan
>
>
>
>
[-- Attachment #2 --]
--- libatalk/util/getiface.c.orig Thu Sep 13 00:28:21 2001
+++ libatalk/util/getiface.c Thu Sep 13 00:28:30 2001
@@ -43,13 +43,6 @@
{
/* if we've run out of room, allocate some more. just return
* the present list if we can't. */
- if (*i >= *length) {
- char **new = realloc(list, sizeof(char **)*(*length + IFACE_NUM));
-
- if (!new) /* just break if we can't allocate anything */
- return -1;
- *length += IFACE_NUM;
- }
if ((list[*i] = strdup(name)) == NULL)
return -1;
@@ -60,30 +53,32 @@
}
-static int getifaces(const int sockfd, char **list, int *length)
+static int getifaces(const int sockfd, char ***list, int *length)
{
#ifdef HAVE_IFNAMEINDEX
struct if_nameindex *ifstart, *ifs;
int i = 0;
+ char **new;
- if (!list || *length < 1)
- return 0;
-
ifs = ifstart = if_nameindex();
+
+ new = (char **) malloc((sizeof(ifs)/sizeof(struct if_nameindex) + 1) * sizeof(char *));
while (ifs && ifs->if_name) {
/* just bail if there's a problem */
- if (addname(list, &i, length, ifs->if_name) < 0)
+ if (addname(new, &i, length, ifs->if_name) < 0)
break;
ifs++;
}
if_freenameindex(ifstart);
+ *list = new;
return i;
#else
struct ifconf ifc;
struct ifreq ifrs[ 64 ], *ifr, *nextifr;
int ifrsize, i = 0;
+ char **new;
if (!list || *length < 1)
return 0;
@@ -96,6 +91,7 @@
return 0;
}
+ new = (char **) malloc((ifc.ifc_len/sizeof(struct ifreq) + 1) * sizeof(char *));
for ( ifr = ifc.ifc_req; ifc.ifc_len >= sizeof( struct ifreq );
ifc.ifc_len -= ifrsize, ifr = nextifr ) {
#ifdef BSD4_4
@@ -108,9 +104,10 @@
nextifr = (struct ifreq *)((caddr_t)ifr + ifrsize );
/* just bail if there's a problem */
- if (addname(list, &i, length, ifr->ifr_name) < 0)
+ if (addname(new, &i, length, ifr->ifr_name) < 0)
break;
}
+ *list = new;
return i;
#endif
}
@@ -122,17 +119,14 @@
*/
char **getifacelist()
{
- char **list = (char **) malloc(sizeof(char **)*(IFACE_NUM + 1));
+ char **list;
char **new;
- int length = IFACE_NUM, i, fd;
+ int length, i, fd;
- if (!list)
- return NULL;
-
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
return NULL;
- if ((i = getifaces(fd, list, &length)) == 0) {
+ if ((i = getifaces(fd, &list, &length)) == 0) {
free(list);
close(fd);
return NULL;
@@ -140,7 +134,7 @@
close(fd);
if ((i < length) &&
- (new = (char **) realloc(list, sizeof(char **)*(i + 1))))
+ (new = (char **) realloc(list, (i + 1) * sizeof(char *))))
return new;
return list;
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010913003010.Y411-200000>
