]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
map files over 2GB could not be loaded
authorEvan Hunt <each@isc.org>
Tue, 24 Aug 2021 19:22:32 +0000 (12:22 -0700)
committerEvan Hunt <each@isc.org>
Wed, 1 Sep 2021 07:43:54 +0000 (00:43 -0700)
- fixed a size comparison using "signed int" that failed if the file
  size was more than 2GB, since that was treated as a negative number.
- incidentally renamed deserialize32() to just deserialize(). we no
  longer have separate 32 and 64 bit rbtdb implementations.

lib/dns/rbt.c
lib/dns/rbtdb.c

index 9a03b49d0f3aa7d23da812cc64810ee7daa969c6..5aee5f63d5068cc95f4c4b73a30506b890bbf9b9 100644 (file)
@@ -777,17 +777,18 @@ treefix(dns_rbt_t *rbt, void *base, size_t filesize, dns_rbtnode_t *n,
        uint64_t *crc) {
        isc_result_t result = ISC_R_SUCCESS;
        dns_fixedname_t fixed;
-       dns_name_t nodename, *fullname;
-       unsigned char *node_data;
+       dns_name_t nodename, *fullname = NULL;
+       unsigned char *node_data = NULL;
        dns_rbtnode_t header;
-       size_t datasize, nodemax = filesize - sizeof(dns_rbtnode_t);
+       size_t nodemax = filesize - sizeof(dns_rbtnode_t);
+       size_t datasize;
 
        if (n == NULL) {
                return (ISC_R_SUCCESS);
        }
 
        CONFIRM((void *)n >= base);
-       CONFIRM((char *)n - (char *)base <= (int)nodemax);
+       CONFIRM((size_t)((char *)n - (char *)base) <= nodemax);
        CONFIRM(DNS_RBTNODE_VALID(n));
 
        dns_name_init(&nodename, NULL);
index 18503950add5c0df00b1a121b047591ed6441d01..51178cc8770ab22788c202f4742f4c3e44a20fbf 100644 (file)
@@ -7596,7 +7596,7 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, void *arg,
  * Load the RBT database from the image in 'f'
  */
 static isc_result_t
-deserialize32(void *arg, FILE *f, off_t offset) {
+deserialize(void *arg, FILE *f, off_t offset) {
        isc_result_t result;
        rbtdb_load_t *loadctx = arg;
        dns_rbtdb_t *rbtdb = loadctx->rbtdb;
@@ -7741,7 +7741,7 @@ beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
 
        callbacks->add = loading_addrdataset;
        callbacks->add_private = loadctx;
-       callbacks->deserialize = deserialize32;
+       callbacks->deserialize = deserialize;
        callbacks->deserialize_private = loadctx;
 
        return (ISC_R_SUCCESS);