Subject: bin/10047: amd with hesiod maps sometimes crashing
To: None <gnats-bugs@gnats.netbsd.org>
From: Mark Davies <mark@MCS.VUW.AC.NZ>
List: netbsd-bugs
Date: 05/04/2000 17:18:12
>Number:         10047
>Category:       bin
>Synopsis:       amd with hesiod maps sometimes crashing
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 04 17:19:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Mark Davies
>Release:        2000/04/09
>Organization:
Dept. of Comp. Sci., Victoria Uni. of Wellington, New Zealand.
>Environment:
	
System: NetBSD city-art.mcs.vuw.ac.nz 1.4X NetBSD 1.4X (MCS_WORKSTATION) #0: Sun Apr 9 10:29:55 NZST 2000 mark@turakirae.mcs.vuw.ac.nz:/src/build/src/sys/arch/i386/compile/MCS_WORKSTATION i386


>Description:
	amd will sometimes coredump when using hesiod maps when looking up
	keys that start with a "."
	
Below is what I sent to the amd and hesiod developers about a year ago when I
first discovered this problem on Digital UNIX. The versions in NetBSD still
have the problem.

Hi,
   This is actually a hesiod bug but it makes amd core dump.

a call to hesiod_resolve in the "new style hesiod" (version 3.0.2 at least)
with a key of the form ".directory.others.u", or any key with a leading "."
returns NULL but _errno has value 0_.

The effect of this on amd is that under these circumstances hesiod_search will 
not set pval but mapc_meta_search which calls it will assume that it has (due
to the lack of an positive errno) and will try to dereference it.

I started seeing this happen a lot once we started running KDE which tends to 
want to look for the file ".directory" in every directory the file manager 
looks at.

My workaround is below:


*** info_hesiod.c~      Thu Feb  4 20:24:15 1999
--- info_hesiod.c       Wed Mar 10 13:30:24 1999
***************
*** 107,112 ****
--- 107,115 ----
         (unsigned long) m, map, key, (unsigned long) pval, (unsigned long) tp);
  #endif /* DEBUG */

+   if (key[0] == '.')
+       return ENOENT;
+
    sprintf(hes_key, "%s.%s", key, map + HES_PREFLEN);

    /*

On the assumption that a key with a leading "." is never valid in a hesiod 
based map.

cheers
mark
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: