[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, Jason Short wrote:
> I think this fix is incomplete.The check for invalid clauses should be
> done in the handle_* function, not in the iteration.Otherwise we risk
> having an error elsewhere where clauses are handled.Invalid requests
> from the client should always be discarded within the handle_* function.
New patch then.
- Per
Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.29
diff -u -r1.29 diptreaty.c
--- common/diptreaty.c 22 Jan 2005 19:45:41 -0000 1.29
+++ common/diptreaty.c 26 Jan 2005 01:20:58 -0000
@@ -130,6 +130,11 @@
enum diplstate_type ds =
pplayer_get_diplstate(ptreaty->plr0, ptreaty->plr1)->type;
+ if (type < 0 || type >= CLAUSE_LAST) {
+ freelog(LOG_ERROR, "Illegal clause type encountered.");
+ return FALSE;
+ }
+
if (type == CLAUSE_ADVANCE && !tech_exists(val)) {
freelog(LOG_ERROR, "Illegal tech value %i in clause.", val);
return FALSE;
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 26 Jan 2005 01:20:58 -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 */
|
|