diff --git a/src/lib/common/xundump.c b/src/lib/common/xundump.c index 1301d7de..e361c8bc 100644 --- a/src/lib/common/xundump.c +++ b/src/lib/common/xundump.c @@ -82,6 +82,7 @@ static struct castr **fldca; /* Map field number to selector */ static int *fldidx; /* Map field number to index */ static int *caflds; /* Map selector number to #fields seen */ static int *cafldspp; /* ditto, in previous parts */ +static int may_omit_id; /* Okay to omit IDs? */ static int may_trunc; /* Okay to truncate? */ static int gripe(char *, ...) ATTRIBUTE((format (printf, 1, 2))); @@ -224,6 +225,8 @@ tbl_skip_to_obj(int id) int max_id, exp_id; if (partno == 0) { + if (!may_omit_id && id != cur_id + 1) + return gripe("Expected %d in field %d", cur_id + 1, 1); if (id <= cur_id) return gripe("Field %d must be > %d", 1, cur_id); max_id = ef_id_limit(cur_type); @@ -1075,13 +1078,14 @@ xundump(FILE *fp, char *file, int *plno, int expected_table) return -1; nca = nf = 0; + may_omit_id = 1; may_trunc = empfile[type].nent < 0; for (i = 0; ca[i].ca_name; i++) { nca++; if (!(ca[i].ca_flags & NSC_EXTRA)) { nf += MAX(1, ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0); if (ca[i].ca_flags & NSC_CONST) - may_trunc = 0; + may_omit_id = may_trunc = 0; } } fldca = malloc(nf * sizeof(*fldca));