Subject: bin/7378: recent fix to "amd" is not quite correct.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <paul@plectere.com>
List: netbsd-bugs
Date: 04/13/1999 22:17:28
>Number:         7378
>Category:       bin
>Synopsis:       recent fix to "amd" is not quite correct.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 13 22:05:01 1999
>Last-Modified:
>Originator:     Paul Shupak
>Organization:
>Release:        NetBSD-current as of Apr 13 1999
>Environment:
System: NetBSD cobalt 1.4_ALPHA NetBSD 1.4_ALPHA (COBALT) #150: Sat Apr 3 11:28:31 PST 1999 paul@cobalt:/usr/src/sys/arch/i386/compile/COBALT i386


>Description:
	Attempt to access a non-existant host by means of a wildcarded host-map
	cause "amd" to coredump ( after referencing a null pointer ).
>How-To-Repeat:

	Create a host map similar to the examples in the documentation
	e.g. a file containing

/defaults       type:=host;fs:=${autodir}/${rhost}/root;rhost:=${key}
*               opts:=ro,nosuid,grpid,resvport

	Then a a command prompt type any reference to a hostname which
	can't be resolved -- ex.

		% ls /net/MachineWhichDoesn_tExist
	
>Fix:
		Call the "extra" RPC ( for SunOS 4.x compatability ) if
	and only if we have a valid sockaddr struct to pass as a parameter.
	NOTE:  Also, do the call after we might have "default"'ed the
	protocol to "udp", not before.

*** /usr/src/usr.sbin/amd/amd/srvr_nfs.c-ORIG	Thu Apr  8 04:28:36 1999
--- /usr/src/usr.sbin/amd/amd/srvr_nfs.c	Tue Apr 13 20:36:28 1999
***************
*** 755,768 ****
  #endif /* not HAVE_FS_NFS3 */
    }
  
-   /*    
-    * XXX RPC or SunOS 4.1.4 bug ? the last call to nfs_get_version() must  
-    * be done with the used version and proto  
-    */  
-   (void)get_nfs_version(host, ip, nfs_version, nfs_proto);  
- 
    if (!nfs_proto)
      nfs_proto = "udp";
  
    plog(XLOG_INFO, "Using NFS version %d, protocol %s on host %s",
         (int) nfs_version, nfs_proto, host);
--- 755,770 ----
  #endif /* not HAVE_FS_NFS3 */
    }
  
    if (!nfs_proto)
      nfs_proto = "udp";
+ 
+   if (ip) {
+     /*    
+      * XXX RPC or SunOS 4.1.4 bug ? the last call to nfs_get_version() must  
+      * be done with the used version and proto  
+      */  
+     (void)get_nfs_version(host, ip, nfs_version, nfs_proto);  
+   }
  
    plog(XLOG_INFO, "Using NFS version %d, protocol %s on host %s",
         (int) nfs_version, nfs_proto, host);
>Audit-Trail:
>Unformatted: