From 7e95b52bce114a0f0d23f215a837936531fd68bd Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 7 May 2011 21:05:02 +0200 Subject: [PATCH] Fix empdump to check for truncation failure xubody() neglected to check ef_truncate()'s return value. Two failure modes: invalid arguments, and ftruncate() failure. The former shouldn't happen, and the latter can happen only for file-backed tables, hence only in empdump -i. --- src/lib/common/xundump.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/common/xundump.c b/src/lib/common/xundump.c index 74a274ca..4f1ad999 100644 --- a/src/lib/common/xundump.c +++ b/src/lib/common/xundump.c @@ -996,9 +996,10 @@ xubody(FILE *fp) maxid = ep->fids; if (maxid < ep->fids) { if (EF_IS_GAME_STATE(cur_type) - || (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)) - ef_truncate(cur_type, maxid); - else + || (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)) { + if (!ef_truncate(cur_type, maxid)) + return -1; + } else return gripe("Table %s requires %d rows, got %d", ef_nameof(cur_type), ep->fids, maxid); }