Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12870) Bad Unit Role Name Crashes Server
Home

[Freeciv-Dev] (PR#12870) Bad Unit Role Name Crashes Server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12870) Bad Unit Role Name Crashes Server
From: "Benedict Adamson" <badamson@xxxxxxxxxxx>
Date: Fri, 22 Apr 2005 14:18:28 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12870 >

The unit rule-set code in ruleset.c, function load_ruleset_units 
carefully checks for and logs bad role names:
       ival = unit_role_from_str(sval);
       if (ival==L_LAST) {
        freelog(LOG_ERROR, "for unit_type \"%s\": bad role name \"%s\" (%s)",
             u->name, sval, filename);
       }
Unfortunately, that code is immediately followed by code that requires 
that ival!=L_LAST, on pain of an assertion failure:
       BV_SET(u->roles, ival - L_FIRST);
       assert(unit_has_role(i, ival));
Therefore a simple typo in units.ruleset will crash the server.

The server should halt gracefully if a ruleset has fatal errors.

I guess the fix is something like this:
       if (ival==L_LAST) {
        freelog(LOG_ERROR, "for unit_type \"%s\": bad role name \"%s\" (%s)",
             u->name, sval, filename);
       } else {
         BV_SET(u->roles, ival - L_FIRST);
         assert(unit_has_role(i, ival));
       }





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12870) Bad Unit Role Name Crashes Server, Benedict Adamson <=