Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] Re: (PR#12016) Pubserver civserver crash in diplomacy
Home

[Freeciv-Dev] Re: (PR#12016) Pubserver civserver crash in diplomacy

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: paul@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12016) Pubserver civserver crash in diplomacy
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 25 Jan 2005 15:52:21 -0800
Reply-to: bugs@xxxxxxxxxxx

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

On Tue, 25 Jan 2005, Paul Zastoupil wrote:
> Unknown clause type in advdiplomacy.c
> CLAUSE_LAST

Weird. I have no idea why this occurs.

However, looking at this code, I realize that it is possible to DOS the
server by sending an illegal clause type. I doubt this is what happened
here, though. Possibly an older beta client using a newer beta server is
the reason for this.

I've fixed this in two places, to be sure it doesn't crop up again. Patch
attached.

  - Per

Index: common/diptreaty.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.h,v
retrieving revision 1.19
diff -u -r1.19 diptreaty.h
--- common/diptreaty.h  22 Jan 2005 20:31:11 -0000      1.19
+++ common/diptreaty.h  25 Jan 2005 23:49:30 -0000
@@ -29,9 +29,11 @@
 #define SPECLIST_TYPE struct Clause
 #include "speclist.h"
 
-#define clause_list_iterate(clauselist, pclause) \
-    TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)
-#define clause_list_iterate_end  LIST_ITERATE_END
+#define clause_list_iterate(clauselist, pclause)             \
+    TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)   \
+    if (pclause->type > 0 && pclause->type < CLAUSE_LAST) {
+#define clause_list_iterate_end                              \
+    } LIST_ITERATE_END
 
 struct Clause {
   enum clause_type type;
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.57
diff -u -r1.57 advdiplomacy.c
--- ai/advdiplomacy.c   22 Jan 2005 20:31:11 -0000      1.57
+++ ai/advdiplomacy.c   25 Jan 2005 23:49:31 -0000
@@ -461,8 +461,7 @@
       worth = 0; /* We don't need no stinkin' embassy, do we? */
     }
     break;
-  default:
-    die("Unknown clause type in advdiplomacy.c");
+  case CLAUSE_LAST:
     break;
   } /* end of switch */
 

[Prev in Thread] Current Thread [Next in Thread]