diff --git a/include/file.h b/include/file.h index 73be69bd..ac6f39e5 100644 --- a/include/file.h +++ b/include/file.h @@ -27,7 +27,7 @@ * file.h: Describes Empire tables (`files' for historical reasons) * * Known contributors to this file: - * Markus Armbruster, 2005-2012 + * Markus Armbruster, 2005-2014 */ #ifndef FILE_H @@ -130,6 +130,12 @@ struct emptypedstr { /* Create table file, clobbering any existing file */ #define EFF_CREATE bit(16) +/* + * A value larger than any struct empfile member size where member + * cadef is not null. + */ +#define EF_WITH_CADEF_MAX_ENTRY_SIZE 1024 + /* * Empire `file types' * These are really table IDs. Some tables are backed by files, some diff --git a/src/lib/commands/xdump.c b/src/lib/commands/xdump.c index 3b245b66..e7b6853b 100644 --- a/src/lib/commands/xdump.c +++ b/src/lib/commands/xdump.c @@ -27,7 +27,7 @@ * xdump.c: Extended dump * * Known contributors to this file: - * Markus Armbruster, 2004-2011 + * Markus Armbruster, 2004-2014 */ #include @@ -140,7 +140,7 @@ xditem(struct xdstr *xd, int type, char *arg) struct castr *ca; struct nstr_item ni; int n; - char buf[2048]; /* FIXME buffer size? */ + unsigned char buf[EF_WITH_CADEF_MAX_ENTRY_SIZE]; ca = ef_cadef(type); if (!ca) diff --git a/src/lib/common/filetable.c b/src/lib/common/filetable.c index 36f687ff..69b4b7c2 100644 --- a/src/lib/common/filetable.c +++ b/src/lib/common/filetable.c @@ -27,11 +27,12 @@ * filetable.c: Empire game data file descriptions. * * Known contributors to this file: - * Markus Armbruster, 2005-2013 + * Markus Armbruster, 2005-2014 */ #include +#include #include #include "commodity.h" #include "file.h" @@ -394,6 +395,11 @@ empfile_init(void) void empfile_fixup(void) { + struct empfile *ep; + empfile[EF_SECTOR].nent = WORLD_SZ(); empfile[EF_MAP].size = empfile[EF_BMAP].size = WORLD_SZ(); + + for (ep = empfile; ep->uid >= 0; ep++) + assert(!ep->cadef || ep->size <= EF_WITH_CADEF_MAX_ENTRY_SIZE); }