From owner-freebsd-ports Tue Dec 28 3:30: 5 1999 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 5A25F1513F for ; Tue, 28 Dec 1999 03:30:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id DAA22108; Tue, 28 Dec 1999 03:30:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from dor.zaural.ru (dor.zaural.ru [195.161.56.129]) by hub.freebsd.org (Postfix) with ESMTP id 6C2D214D6D for ; Tue, 28 Dec 1999 03:26:12 -0800 (PST) (envelope-from serg@dor.zaural.ru) Received: (from serg@localhost) by dor.zaural.ru (8.9.3/8.9.3) id QAA20429; Tue, 28 Dec 1999 16:26:00 +0500 (YEKT) (envelope-from serg) Message-Id: <199912281126.QAA20429@dor.zaural.ru> Date: Tue, 28 Dec 1999 16:26:00 +0500 (YEKT) From: serg@dor.zaural.ru Reply-To: serg@dor.zaural.ru To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: ports/15741: joe editor coredumps when read a file using ^K-R Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 15741 >Category: ports >Synopsis: joe editor coredumps when read a file using ^K-R >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Dec 28 03:30:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Sergey N. Voronkov >Release: FreeBSD 3.4-STABLE i386 >Organization: Dorojnik, Kurgan >Environment: Any. Code bug. >Description: Joe dump core file when read a file using ^K-R. Problem is NULL-pointer assigment in b.c, patched line with b->filehandle (b is uninitialized). >How-To-Repeat: Open any file and try to insert another one into it. >Fix: Change patch-ad to this: --- b.c.orig Fri Jan 20 13:38:25 1995 +++ b.c Tue Dec 28 15:56:10 1999 @@ -22,4 +22,7 @@ #endif #include +#include +#include +#include #include "config.h" @@ -202,4 +205,5 @@ else b->o=pdefault; mset(b->marks,0,sizeof(b->marks)); + b->filehandle = -1; /* initialize filehandle &&& ob */ b->rdonly=0; b->orphan=0; @@ -256,4 +260,8 @@ if(b && !--b->count) { + if (b->filehandle != -1) { + /* close filehandle, free lock &&& ob */ + close (b->filehandle); + } if(b->changed) abrerr(b->name); if(b==errbuf) errbuf=0; @@ -1672,5 +1680,6 @@ long skip,amnt; char *n; - int nowrite=0; + struct stat sb; + int nowrite=0,fh=-1; if(!s || !s[0]) @@ -1705,4 +1714,26 @@ fi=fopen(n,"r"); if(!fi) nowrite=0; +/*printf ("nowrite open=%i\n", nowrite); */ + + /* check file mod, if no write flags set, + joe in read only mode. &&& ob */ + + if (!nowrite) { + nowrite = (!stat (n, &sb)) && (!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))); + } +/*printf ("nowrite stat=%i\n", nowrite); */ + + /* lock the file if writable, or go into read only mode if + already locked, */ + + if ((fi) && (!nowrite)) { + fh = dup( fileno(fi) ); + nowrite = (flock (fh, LOCK_EX | LOCK_NB)); + } +/*printf ("nowrite flock=%i\n", nowrite); */ + +/*nowrite = 1; */ /* for test purpose */ +/*printf ("nowrite=%i\n", nowrite); */ + } joesep(n); @@ -1762,4 +1793,5 @@ b->er=error; + if( fh != -1 ) b->filehandle = fh; return b; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message