*
* The `makekey` method fills in a `dns_qpkey_t` corresponding to a
* value object stored in the qp-trie. It returns the length of the
- * key. This method will typically call dns_qpkey_fromname() with a
- * name stored in the value object.
+ * key, which must be less than `sizeof(dns_qpkey_t)`. This method
+ * will typically call dns_qpkey_fromname() with a name stored in the
+ * value object.
*
* For logging and tracing, the `triename` method copies a human-
* readable identifier into `buf` which has max length `size`.
* Requires:
* \li `name` is a pointer to a valid `dns_name_t`
*
+ * Ensures:
+ * \li returned length is less than `sizeof(dns_qpkey_t)`
+ *
* Returns:
* \li the length of the key
*/
isc_result_t
-dns_qp_getkey(dns_qpreadable_t qpr, const dns_qpkey_t searchk, size_t searchl,
- void **pval_r, uint32_t *ival_r);
+dns_qp_getkey(dns_qpreadable_t qpr, const dns_qpkey_t search_key,
+ size_t search_keylen, void **pval_r, uint32_t *ival_r);
/*%<
- * Find a leaf in a qp-trie that matches the given key
+ * Find a leaf in a qp-trie that matches the given search key
*
* The leaf values are assigned to `*pval_r` and `*ival_r`
*
* \li `qpr` is a pointer to a readable qp-trie
* \li `pval_r != NULL`
* \li `ival_r != NULL`
+ * \li `search_keylen < sizeof(dns_qpkey_t)`
*
* Returns:
* \li ISC_R_NOTFOUND if the trie has no leaf with a matching key
*/
isc_result_t
-dns_qp_deletekey(dns_qp_t *qp, const dns_qpkey_t key, size_t len);
+dns_qp_deletekey(dns_qp_t *qp, const dns_qpkey_t key, size_t keylen);
/*%<
* Delete a leaf from a qp-trie that matches the given key
*
* Requires:
* \li `qp` is a pointer to a valid qp-trie
+ * \li `keylen < sizeof(dns_qpkey_t)`
*
* Returns:
* \li ISC_R_NOTFOUND if the trie has no leaf with a matching key
static inline size_t
leaf_qpkey(dns_qpreadable_t qpr, qp_node_t *n, dns_qpkey_t key) {
dns_qpreader_t *qp = dns_qpreader(qpr);
- return (qp->methods->makekey(key, qp->uctx, leaf_pval(n),
- leaf_ival(n)));
+ size_t len = qp->methods->makekey(key, qp->uctx, leaf_pval(n),
+ leaf_ival(n));
+ INSIST(len < sizeof(dns_qpkey_t));
+ return (len);
}
static inline char *