Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 1999 19:05:07 -0700 (PDT)
From:      krentel@dreamscape.com
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/13278: rogue: killed by fire corrupts score file
Message-ID:  <19990821020507.12A4614D2F@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         13278
>Category:       bin
>Synopsis:       rogue: killed by fire corrupts score file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 20 19:10:00 PDT 1999
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990821020507.12A4614D2F>