[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]
<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 */
- [Freeciv-Dev] Re: (PR#12016) Pubserver civserver crash in diplomacy,
Per I. Mathisen <=
|
|