From ryan@home.sasknow.net  Thu Apr 19 02:43:27 2001
Return-Path: <ryan@home.sasknow.net>
Received: from home.sasknow.net (stimpy.sasknow.net [207.195.92.134])
	by hub.freebsd.org (Postfix) with ESMTP id A1BDF37B43C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 19 Apr 2001 02:43:26 -0700 (PDT)
	(envelope-from ryan@home.sasknow.net)
Received: (from ryan@localhost)
	by home.sasknow.net (8.11.3/8.11.3) id f3J3hfN36175;
	Thu, 19 Apr 2001 03:43:41 GMT
	(envelope-from ryan)
Message-Id: <200104190343.f3J3hfN36175@home.sasknow.net>
Date: Thu, 19 Apr 2001 03:43:41 GMT
From: ryan@sasknow.com
Reply-To: ryan@sasknow.com
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: PATCH: editors/lpe 1.2.5 segfault on permission denied
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         26698
>Category:       ports
>Synopsis:       PATCH: editors/lpe 1.2.5 segfault on permission denied
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 19 02:50:01 PDT 2001
>Closed-Date:    Mon Apr 23 15:47:49 PDT 2001
>Last-Modified:  Mon Apr 23 15:49:24 PDT 2001
>Originator:     Ryan Thompson
>Release:        FreeBSD 4.2-20010325-STABLE i386
>Organization:
>Environment:
System: FreeBSD home.sasknow.net 4.2-20010325-STABLE FreeBSD 4.2-20010325-STABLE #0: Sun Mar 25 12:57:18 GMT 2001 root@usw3.freebsd.org:/usr/src/sys/compile/GENERIC i386

>Description:
	lpe 1.2.5 as built from today's ports (nothing 
	interesting in the commit logs anyway) will dump 
	core without fail when a file when fopen() fails 
	on an existing file (eg, permission denied)

	The homespun die() lpe.c incorrectly tries to
	free() each node in the doubly linked list of 
	lines of text in its internal storage buffer,
	when (portions of) that buffer may not have been
	initialized as a result of a premature exit.

>How-To-Repeat:
	chmod 000 somefile
	lpe somefile
	(as a normal user ;-)

>Fix:
	Solution is to prevent die() from free()ing
	nodes if the text buffer is null. 


--- lpe.c.orig	Thu Apr 19 02:16:41 2001
+++ lpe.c	Thu Apr 19 03:08:30 2001
@@ -48,13 +48,17 @@
 {
     buffer *node;
 
-    while (the_buf->next != the_buf)
+    if (the_buf->text != NULL)
     {
-        node = the_buf->next;
-        the_buf->next = the_buf->next->next;
-        the_buf->next->prev = the_buf;
-        free(node);
+    	while (the_buf->next != the_buf)
+    	{
+	        node = the_buf->next;
+	        the_buf->next = the_buf->next->next;
+	        the_buf->next->prev = the_buf;
+	        free(node);
+    	}
     }
+    	
     free(the_buf);
 }
 
>Release-Note:
>Audit-Trail:

From: Jimmy Olgeni <olgeni@FreeBSD.org>
To: <freebsd-gnats-submit@FreeBSD.org>, <ryan@sasknow.com>
Cc: <calle.madestrand@norrgarden.se>
Subject: Re: ports/26698: PATCH: editors/lpe 1.2.5 segfault on permission
 denied
Date: Fri, 20 Apr 2001 16:10:34 +0200 (CEST)

 Looks like this should be added to files/.
 
 Did you submit this patch to maintainer?
 
 (new email address: calle.madestrand@norrgarden.se)
 
 You may also wish to submit this patch to the lpe authors too, since
 it's a generic bugfix not specific to FreeBSD only.
 
 Thanks!
 
 -- 
 jimmy
 

From: Ryan Thompson <ryan@sasknow.com>
To: Jimmy Olgeni <olgeni@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, calle.madestrand@norrgarden.se
Subject: Re: ports/26698: PATCH: editors/lpe 1.2.5 segfault on permission
 denied
Date: Fri, 20 Apr 2001 15:01:13 -0600 (CST)

 Jimmy Olgeni wrote to freebsd-gnats-submit@FreeBSD.org and ryan@sasknow.com:
 
 > Looks like this should be added to files/.
 
 Yes.
 
 > Did you submit this patch to maintainer?
 
 Yes.
 
 > (new email address: calle.madestrand@norrgarden.se)
 > 
 > You may also wish to submit this patch to the lpe authors too, since
 > it's a generic bugfix not specific to FreeBSD only.
 
 Yes.
 
 > Thanks!
 > 
 
 You're welcome! ;-)
 
 - Ryan
 
 -- 
   Ryan Thompson <ryan@sasknow.com>
   Network Administrator, Accounts
 
   SaskNow Technologies - http://www.sasknow.com
   #106-380 3120 8th St E - Saskatoon, SK - S7H 0W2
 
         Tel: 306-664-3600   Fax: 306-664-1161   Saskatoon
   Toll-Free: 877-727-5669     (877-SASKNOW)     North America
 
State-Changed-From-To: open->closed 
State-Changed-By: olgeni 
State-Changed-When: Mon Apr 23 15:47:49 PDT 2001 
State-Changed-Why:  
Patch approved by maintainer in ports/26804, and committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26698 
>Unformatted:
