From nobody@FreeBSD.ORG Fri Aug 20 19:05:52 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 12A4614D2F; Fri, 20 Aug 1999 19:05:07 -0700 (PDT)
Message-Id: <19990821020507.12A4614D2F@hub.freebsd.org>
Date: Fri, 20 Aug 1999 19:05:07 -0700 (PDT)
From: krentel@dreamscape.com
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: rogue: killed by fire corrupts score file
X-Send-Pr-Version: www-1.0

>Number:         13278
>Category:       bin
>Synopsis:       rogue: killed by fire corrupts score file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 20 19:10:00 PDT 1999
>Closed-Date:    Wed May 23 14:01:05 PDT 2001
>Last-Modified:  Wed May 23 14:01:19 PDT 2001
>Originator:     Mark W. Krentel
>Release:        3.2-release
>Organization:
none
>Environment:
3.2-release

>Description:
I'm embarrassed to be sending a PR on rogue, but I have a fix and it's
an excuse to bug you about a couple other things.

When a game ends that makes the top 10, the function insert_score in
score.c is called to make the new score file.  But the case for KFIRE
(killed by fire) incorrectly uses strcpy instead of strcat (all the
other cases use strcat).  This puts the string in the wrong place and
corrupts the score file.

Also, I've never really liked the fact that a make world resets the
score file to empty (the beforeinstall target in Makefile).  I just
delete the beforeinstall target, but probably a better solution is to
test if the score file exists and install a new one only if it doesn't.

Finally, would it be possible to MFC all the fixes from NetBSD back in
April 99 (PR 8083) into 3.x?

>How-To-Repeat:
Go down to level 21+, stand on a scroll of scare monster and let a 
Dragon flame you to death.  But first save a copy of the score file.

>Fix:
For the killed by fire problem:

% diff -u score.c.orig score.c
--- score.c.orig        Thu Aug 19 19:46:06 1999
+++ score.c     Thu Aug 19 20:06:27 1999
@@ -356,7 +356,7 @@
                        (void) strcat(buf, "a total winner");
                        break;
                case KFIRE:
-                       (void) strcpy(buf, "killed by fire");
+                       (void) strcat(buf, "killed by fire");
                        break;
                }
        } else {

--------------------------------

To avoid make world clobbering the score file:

% diff -u Makefile.orig Makefile
--- Makefile.orig       Thu Aug 19 19:46:01 1999
+++ Makefile    Thu Aug 19 20:04:34 1999
@@ -11,6 +11,7 @@
 MAN6=  rogue.6
 
 beforeinstall:
+       [ -f ${DESTDIR}/var/games/rogue.scores ] || \
        ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
            ${DESTDIR}/var/games/rogue.scores
 

>Release-Note:
>Audit-Trail:

From: Tim Vanderhoek <tim@ppp18344.on.bellglobal.com>
To: freebsd-gnats-submit@freebsd.org, krentel@dreamscape.com
Cc:  
Subject: Re: bin/13278: rogue: killed by fire corrupts score 
Date: Sat, 21 Aug 1999 23:45:47 -0400 (EDT)

 >
 >To avoid make world clobbering the score file:
 >
 >% diff -u Makefile.orig Makefile
 >--- Makefile.orig       Thu Aug 19 19:46:01 1999
 
 Originator notes that bin/13068 contains a more comprehensive fix for
 this latter problem (but _not_ the former).
 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Wed May 23 14:01:05 PDT 2001 
State-Changed-Why:  
Committed (with some delay), Thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=13278 
>Unformatted:
