Fix for Program hack in bsdgames-2.17.25 core dumps when you enter 'i' after restoring a saved game

Bug #1758805 reported by Richard Henschel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bsdgames (Ubuntu)
New
Undecided
Unassigned

Bug Description

The following patch fixes the problem. Cut and paste may have converted tabs to spaces (sorry).
I sent this to lists.debian.org as well, but not sure if that is the right place.
I am running Ubuntu 17.10 and package lists as bsdgames-2.17-25, but this fix was done in source listed as bsdgames-2,17-26build1, so that version is also broken.

*** hack.o_init.c.old 2003-12-16 20:47:37.000000000 -0600
--- hack.o_init.c 2018-03-25 20:35:59.362696144 -0600
***************
*** 184,191 ****
   bwrite(fd, (char *) bases, sizeof bases);
   bwrite(fd, (char *) objects, sizeof objects);
   /*
! * as long as we use only one version of Hack/Quest we need not save
! * oc_name and oc_descr, but we must save oc_uname for all objects
    */
   for (i = 0; i < SIZE(objects); i++) {
    if (objects[i].oc_uname) {
--- 184,190 ----
   bwrite(fd, (char *) bases, sizeof bases);
   bwrite(fd, (char *) objects, sizeof objects);
   /*
! * Save oc_name, oc_descr, as well as oc_uname for all objects
    */
   for (i = 0; i < SIZE(objects); i++) {
    if (objects[i].oc_uname) {
***************
*** 193,198 ****
--- 192,207 ----
     bwrite(fd, (char *) &len, sizeof len);
     bwrite(fd, objects[i].oc_uname, len);
    }
+ if (objects[i].oc_name) {
+ len = strlen(objects[i].oc_name) + 1;
+ bwrite(fd, (char *) &len, sizeof len);
+ bwrite(fd, objects[i].oc_name, len);
+ }
+ if (objects[i].oc_descr) {
+ len = strlen(objects[i].oc_descr) + 1;
+ bwrite(fd, (char *) &len, sizeof len);
+ bwrite(fd, objects[i].oc_descr, len);
+ }
   }
  }

***************
*** 205,215 ****
--- 214,236 ----
   mread(fd, (char *) bases, sizeof bases);
   mread(fd, (char *) objects, sizeof objects);
   for (i = 0; i < SIZE(objects); i++)
+ {
    if (objects[i].oc_uname) {
     mread(fd, (char *) &len, sizeof len);
     objects[i].oc_uname = (char *) alloc(len);
     mread(fd, objects[i].oc_uname, len);
    }
+ if (objects[i].oc_name) {
+ mread(fd, (char *) &len, sizeof len);
+ objects[i].oc_name = (char *) alloc(len);
+ mread(fd, objects[i].oc_name, len);
+ }
+ if (objects[i].oc_descr) {
+ mread(fd, (char *) &len, sizeof len);
+ objects[i].oc_descr = (char *) alloc(len);
+ mread(fd, objects[i].oc_descr, len);
+ }
+ }
  }

  int

tags: added: 2.17.28 close dr. in included please quathamer tobias version
summary: - Program hack in bsdgames-2.17.25 core dumps when you enter 'i' after
- restoring a saved game
+ Fix for Program hack in bsdgames-2.17.25 core dumps when you enter 'i'
+ after restoring a saved game
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.