From nobody  Mon Sep 29 09:43:11 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id JAA21495;
          Mon, 29 Sep 1997 09:43:11 -0700 (PDT)
Message-Id: <199709291643.JAA21495@hub.freebsd.org>
Date: Mon, 29 Sep 1997 09:43:11 -0700 (PDT)
From: jlind@skypoint.com
To: freebsd-gnats-submit@freebsd.org
Subject: fclose on NULL pointer causes rdist to Seg V with remote rdist can't run
X-Send-Pr-Version: www-1.0

>Number:         4652
>Category:       bin
>Synopsis:       fclose on NULL pointer causes rdist to Seg V with remote rdist can't run
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 29 09:50:00 PDT 1997
>Closed-Date:    Thu Oct 9 07:11:28 PDT 1997
>Last-Modified:  Thu Oct  9 07:12:23 PDT 1997
>Originator:     John Lind
>Release:        2.2.2
>Organization:
SkyPoint Communications, Inc.
>Environment:
FreeBSD mirage.skypoint.com 2.2.2-RELEASE FreeBSD 2.2.2-RELEASE #0: Tue Aug 26 1
4:41:47 CDT 1997     root@oasis.skypoint.net:/usr/src/sys/compile/OASIS  i386

>Description:
The setjmp in doarrow (docmd.c line 145) happens before the makeconn and logfile
opens.  If the rsh->rdist remote execution fails early on, lostconn
will be called in makeconn before the log file open occurs, causing
the longjmp to occur, transfer to the label "done" and there try to
do an fclose on lfp, which is uninitialized.
>How-To-Repeat:
One easy way -- remove the execute permission on rdist on the remote
system.
>Fix:
I simply protected the fclose(lfp) with a test for NULL and made sure
that lfp was initialized to NULL (for systems that don't do clearcore or
whatever).  It is arguable whether this is correct.  Perhaps moving the
setjmp down or the logfile open up would be better.  I didn't have sufficient
familiarity with the code to propose the "correct" solution and send in
a patch.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Thu Oct 9 07:11:28 PDT 1997 
State-Changed-Why:  
Checking lfp for NULL before closing it is indeed the best solution and 
should work fine.  Done, thanks! 
>Unformatted:
