]> 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 15:01:27 +0000 (08:01 -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 4cfc1769af3b22ed77948ec10996fb8645b9e5b4..f845725f475686fed06198c813609e31d4077fda 100644 (file)
@@ -775,17 +775,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 3b5035ea349e9c751b8e6a6682084dc5561da95b..a5068d0f3a7444a630bf0728f87587b9e783d85d 100644 (file)
@@ -7579,7 +7579,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;
@@ -7724,7 +7724,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);