diff options
author | Jim Meyering <meyering@redhat.com> | 2010-01-20 21:31:40 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-05-09 20:43:29 +0200 |
commit | eb170e813979f81b9103f51d3616de29389e4513 (patch) | |
tree | b5e0bcc61c82644ea4869036455fd6f6f996875b | |
parent | 42ee8e731e7e0906d9ee458a37fb26370eee2d55 (diff) | |
download | idutils-eb170e813979f81b9103f51d3616de29389e4513.tar.gz idutils-eb170e813979f81b9103f51d3616de29389e4513.tar.bz2 idutils-eb170e813979f81b9103f51d3616de29389e4513.zip |
mkid: use ftello (not ftell) and fail if an offset is 2^32 or larger
This is necessary because the internal layout requires that an
offset be representable as a 4-byte quantity.
* src/mkid.c (write_id_file): Use ftello, not ftell.
The latter would fail on files larger than 4GiB. Now,
we still fail for such files, but use ftello instead --
and give a diagnostic.
m--------- | gnulib | 0 | ||||
-rw-r--r-- | src/mkid.c | 15 |
2 files changed, 12 insertions, 3 deletions
diff --git a/gnulib b/gnulib -Subproject 0c6cf5ab43555377b99d94febb2d6f23fc3d2cb +Subproject 880f2b69df57af506439d6aaf1fe185a6f960e4 @@ -710,14 +710,20 @@ write_id_file (struct idhead *idhp) /* write out the list of pathnames */ fseek (idhp->idh_FILE, sizeof_idhead (), 0); - idhp->idh_flinks_offset = ftell (idhp->idh_FILE); + off_t off = ftello (idhp->idh_FILE); + if (UINT32_MAX < off) + error (EXIT_FAILURE, 0, _("internal limitation: offset of 2^32 or larger")); + idhp->idh_flinks_offset = off; serialize_file_links (idhp); /* write out the list of identifiers */ putc ('\0', idhp->idh_FILE); putc ('\0', idhp->idh_FILE); - idhp->idh_tokens_offset = ftell (idhp->idh_FILE); + off = ftello (idhp->idh_FILE); + if (UINT32_MAX < off) + error (EXIT_FAILURE, 0, _("internal limitation: offset of 2^32 or larger")); + idhp->idh_tokens_offset = off; for (i = 0; i < token_table.ht_fill; i++, tokens++) { @@ -761,7 +767,10 @@ write_id_file (struct idhead *idhp) } assert_hits (summary_root); idhp->idh_tokens = token_table.ht_fill; - output_length = ftell (idhp->idh_FILE); + off = ftello (idhp->idh_FILE); + if (UINT32_MAX < off) + error (EXIT_FAILURE, 0, _("internal limitation: offset of 2^32 or larger")); + output_length = off; idhp->idh_end_offset = output_length - 2; idhp->idh_buf_size = max_buf_size; idhp->idh_vec_size = max_vec_size; |