mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
[master] fix corrupt map file handling
3564. [bug] Improved handling of corrupted map files. [RT #33380]
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,3 +1,5 @@
|
|||||||
|
3564. [bug] Improved handling of corrupted map files. [RT #33380]
|
||||||
|
|
||||||
3563. [contrib] zone2sqlite failed with some table names. [RT #33375]
|
3563. [contrib] zone2sqlite failed with some table names. [RT #33375]
|
||||||
|
|
||||||
3562. [func] Update map file header format to include a SHA-1 hash
|
3562. [func] Update map file header format to include a SHA-1 hash
|
||||||
|
@@ -241,7 +241,8 @@ ret=0
|
|||||||
./named-compilezone -D -f text -F map -o map.5 example.nil baseline.txt > /dev/null
|
./named-compilezone -D -f text -F map -o map.5 example.nil baseline.txt > /dev/null
|
||||||
cp map.5 badmap
|
cp map.5 badmap
|
||||||
stomp badmap 2754 2 99
|
stomp badmap 2754 2 99
|
||||||
./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null && ret=1
|
./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
|
||||||
|
[ $? = 1 ] || ret=1
|
||||||
[ $ret -eq 0 ] || echo "I:failed"
|
[ $ret -eq 0 ] || echo "I:failed"
|
||||||
status=`expr $status + $ret`
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
@@ -249,7 +250,8 @@ echo "I:checking corrupt map files fail to load (bad node data)"
|
|||||||
ret=0
|
ret=0
|
||||||
cp map.5 badmap
|
cp map.5 badmap
|
||||||
stomp badmap 2897 5 127
|
stomp badmap 2897 5 127
|
||||||
./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null && ret=1
|
./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
|
||||||
|
[ $? = 1 ] || ret=1
|
||||||
[ $ret -eq 0 ] || echo "I:failed"
|
[ $ret -eq 0 ] || echo "I:failed"
|
||||||
status=`expr $status + $ret`
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
|
@@ -776,16 +776,17 @@ dns_rbt_deserialize_tree(void *base_address, off_t header_offset,
|
|||||||
file_header_t *header;
|
file_header_t *header;
|
||||||
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
|
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
|
||||||
isc_sha1_t sha1;
|
isc_sha1_t sha1;
|
||||||
|
dns_rbt_t *rbt = NULL;
|
||||||
|
|
||||||
REQUIRE(originp == NULL || *originp == NULL);
|
REQUIRE(originp == NULL || *originp == NULL);
|
||||||
|
|
||||||
isc_sha1_init(&sha1);
|
isc_sha1_init(&sha1);
|
||||||
|
|
||||||
result = dns_rbt_create(mctx, deleter, deleter_arg, rbtp);
|
result = dns_rbt_create(mctx, deleter, deleter_arg, &rbt);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
(*rbtp)->mmap_location = base_address;
|
rbt->mmap_location = base_address;
|
||||||
|
|
||||||
header = (file_header_t *)((char *)base_address + header_offset);
|
header = (file_header_t *)((char *)base_address + header_offset);
|
||||||
|
|
||||||
@@ -808,21 +809,26 @@ dns_rbt_deserialize_tree(void *base_address, off_t header_offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy other data items from the header into our rbt. */
|
/* Copy other data items from the header into our rbt. */
|
||||||
(*rbtp)->root = (dns_rbtnode_t *)((char *)base_address +
|
rbt->root = (dns_rbtnode_t *)((char *)base_address +
|
||||||
header_offset + header->first_node_offset);
|
header_offset + header->first_node_offset);
|
||||||
(*rbtp)->nodecount = header->nodecount;
|
rbt->nodecount = header->nodecount;
|
||||||
treefix(*rbtp, (*rbtp)->root, dns_rootname, datafixer, &sha1);
|
treefix(rbt, rbt->root, dns_rootname, datafixer, &sha1);
|
||||||
|
|
||||||
isc_sha1_final(&sha1, digest);
|
isc_sha1_final(&sha1, digest);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
hexdump("deserializing digest", digest, sizeof(digest));
|
hexdump("deserializing digest", digest, sizeof(digest));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (memcmp(header->digest, digest, sizeof(digest)) != 0)
|
if (memcmp(header->digest, digest, sizeof(digest)) != 0) {
|
||||||
|
rbt->root = NULL;
|
||||||
|
rbt->nodecount = 0;
|
||||||
|
dns_rbt_destroy(&rbt);
|
||||||
return (ISC_R_INVALIDFILE);
|
return (ISC_R_INVALIDFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*rbtp = rbt;
|
||||||
if (originp != NULL)
|
if (originp != NULL)
|
||||||
*originp = (*rbtp)->root;
|
*originp = rbt->root;
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user