]> git.pond.sub.org Git - empserver/commitdiff
Fix empdump to check for truncation failure
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 7 May 2011 19:05:02 +0000 (21:05 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:49:58 +0000 (16:49 +0200)
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

index 74a274caa85cde5b031b3fefb495d0bccb474e46..4f1ad9994a67264e5a35311d879c8a43385f233a 100644 (file)
@@ -996,9 +996,10 @@ xubody(FILE *fp)
        maxid = ep->fids;
     if (maxid < ep->fids) {
        if (EF_IS_GAME_STATE(cur_type)
        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);
     }
            return gripe("Table %s requires %d rows, got %d",
                         ef_nameof(cur_type), ep->fids, maxid);
     }