mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
lib/isccfg/parser.c: Fix invalid order of DbC checks that could cause dereference before NULL check
This commit is contained in:
@@ -241,7 +241,7 @@ cfg_printx(const cfg_obj_t *obj, unsigned int flags,
|
|||||||
isc_result_t
|
isc_result_t
|
||||||
cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
const cfg_tuplefielddef_t *fields = type->of;
|
const cfg_tuplefielddef_t *fields;
|
||||||
const cfg_tuplefielddef_t *f;
|
const cfg_tuplefielddef_t *f;
|
||||||
cfg_obj_t *obj = NULL;
|
cfg_obj_t *obj = NULL;
|
||||||
unsigned int nfields = 0;
|
unsigned int nfields = 0;
|
||||||
@@ -251,6 +251,8 @@ cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
|||||||
REQUIRE(type != NULL);
|
REQUIRE(type != NULL);
|
||||||
REQUIRE(ret != NULL && *ret == NULL);
|
REQUIRE(ret != NULL && *ret == NULL);
|
||||||
|
|
||||||
|
fields = type->of;
|
||||||
|
|
||||||
for (f = fields; f->name != NULL; f++)
|
for (f = fields; f->name != NULL; f++)
|
||||||
nfields++;
|
nfields++;
|
||||||
|
|
||||||
@@ -272,7 +274,7 @@ isc_result_t
|
|||||||
cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
||||||
{
|
{
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
const cfg_tuplefielddef_t *fields = type->of;
|
const cfg_tuplefielddef_t *fields;
|
||||||
const cfg_tuplefielddef_t *f;
|
const cfg_tuplefielddef_t *f;
|
||||||
cfg_obj_t *obj = NULL;
|
cfg_obj_t *obj = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -281,6 +283,8 @@ cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
|||||||
REQUIRE(type != NULL);
|
REQUIRE(type != NULL);
|
||||||
REQUIRE(ret != NULL && *ret == NULL);
|
REQUIRE(ret != NULL && *ret == NULL);
|
||||||
|
|
||||||
|
fields = type->of;
|
||||||
|
|
||||||
CHECK(cfg_create_tuple(pctx, type, &obj));
|
CHECK(cfg_create_tuple(pctx, type, &obj));
|
||||||
for (f = fields, i = 0; f->name != NULL; f++, i++)
|
for (f = fields, i = 0; f->name != NULL; f++, i++)
|
||||||
CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[i]));
|
CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[i]));
|
||||||
@@ -1797,13 +1801,15 @@ cfg_parse_spacelist(cfg_parser_t *pctx, const cfg_type_t *listtype,
|
|||||||
cfg_obj_t **ret)
|
cfg_obj_t **ret)
|
||||||
{
|
{
|
||||||
cfg_obj_t *listobj = NULL;
|
cfg_obj_t *listobj = NULL;
|
||||||
const cfg_type_t *listof = listtype->of;
|
const cfg_type_t *listof;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
REQUIRE(pctx != NULL);
|
REQUIRE(pctx != NULL);
|
||||||
REQUIRE(listtype != NULL);
|
REQUIRE(listtype != NULL);
|
||||||
REQUIRE(ret != NULL && *ret == NULL);
|
REQUIRE(ret != NULL && *ret == NULL);
|
||||||
|
|
||||||
|
listof = listtype->of;
|
||||||
|
|
||||||
CHECK(cfg_create_list(pctx, listtype, &listobj));
|
CHECK(cfg_create_list(pctx, listtype, &listobj));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -1907,7 +1913,7 @@ cfg_listelt_value(const cfg_listelt_t *elt) {
|
|||||||
isc_result_t
|
isc_result_t
|
||||||
cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
||||||
{
|
{
|
||||||
const cfg_clausedef_t * const *clausesets = type->of;
|
const cfg_clausedef_t * const *clausesets;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
const cfg_clausedef_t * const *clauseset;
|
const cfg_clausedef_t * const *clauseset;
|
||||||
const cfg_clausedef_t *clause;
|
const cfg_clausedef_t *clause;
|
||||||
@@ -1922,6 +1928,8 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
|||||||
REQUIRE(type != NULL);
|
REQUIRE(type != NULL);
|
||||||
REQUIRE(ret != NULL && *ret == NULL);
|
REQUIRE(ret != NULL && *ret == NULL);
|
||||||
|
|
||||||
|
clausesets = type->of;
|
||||||
|
|
||||||
CHECK(create_map(pctx, type, &obj));
|
CHECK(create_map(pctx, type, &obj));
|
||||||
|
|
||||||
obj->value.map.clausesets = clausesets;
|
obj->value.map.clausesets = clausesets;
|
||||||
@@ -3033,12 +3041,14 @@ cfg_print_sockaddr(cfg_printer_t *pctx, const cfg_obj_t *obj) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) {
|
cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) {
|
||||||
const unsigned int *flagp = type->of;
|
const unsigned int *flagp;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
REQUIRE(pctx != NULL);
|
REQUIRE(pctx != NULL);
|
||||||
REQUIRE(type != NULL);
|
REQUIRE(type != NULL);
|
||||||
|
|
||||||
|
flagp = type->of;
|
||||||
|
|
||||||
cfg_print_cstr(pctx, "( ");
|
cfg_print_cstr(pctx, "( ");
|
||||||
if ((*flagp & CFG_ADDR_V4OK) != 0) {
|
if ((*flagp & CFG_ADDR_V4OK) != 0) {
|
||||||
cfg_print_cstr(pctx, "<ipv4_address>");
|
cfg_print_cstr(pctx, "<ipv4_address>");
|
||||||
|
Reference in New Issue
Block a user