3439. [bug] contrib/dlz error checking fixes. [RT #32102]

Conflicts:
	contrib/dlz/example/dlz_example.c
	contrib/dlz/example/dlz_minimal.h

Conflicts:
	contrib/dlz/drivers/dlz_filesystem_driver.c
	contrib/dlz/example/dlz_example.c
	contrib/dlz/example/dlz_minimal.h
This commit is contained in:
Mark Andrews
2012-12-11 13:29:34 +11:00
parent 0fcbd40175
commit ff2d989592
2 changed files with 34 additions and 27 deletions
+2
View File
@@ -1,3 +1,5 @@
3439. [bug] contrib/dlz error checking fixes. [RT #32102]
3438. [bug] Don't accept unknown data escape in quotes. [RT #32031]
3437. [bug] isc_buffer_init -> isc_buffer_constinit to initialise
+32 -27
View File
@@ -108,8 +108,7 @@ fs_destroy(void *driverarg, void *dbdata);
*/
static isc_boolean_t
is_safe(const char *input)
{
is_safe(const char *input) {
unsigned int i;
unsigned int len = strlen(input);
@@ -119,13 +118,13 @@ is_safe(const char *input)
if (input[i] == '.') {
/* '.' is not allowed as first char */
if (i == 0)
return ISC_FALSE;
return (ISC_FALSE);
/* '..', two dots together is not allowed. */
else if (input[i-1] == '.')
return ISC_FALSE;
return (ISC_FALSE);
/* '.' is not allowed as last char */
if (i == len)
return ISC_FALSE;
return (ISC_FALSE);
/* only 1 dot in ok location, continue at next char */
continue;
}
@@ -161,16 +160,14 @@ is_safe(const char *input)
* if we reach this point we have encountered a
* disallowed char!
*/
return ISC_FALSE;
return (ISC_FALSE);
}
/* everything ok. */
return ISC_TRUE;
return (ISC_TRUE);
}
static isc_result_t
create_path_helper(char *out, const char *in, config_data_t *cd)
{
create_path_helper(char *out, const char *in, config_data_t *cd) {
char *tmpString;
char *tmpPtr;
int i;
@@ -238,6 +235,7 @@ create_path(const char *zone, const char *host, const char *client,
int pathsize;
int len;
isc_result_t result;
isc_boolean_t isroot = ISC_FALSE;
/* we require a zone & cd parameter */
REQUIRE(zone != NULL);
@@ -252,16 +250,20 @@ create_path(const char *zone, const char *host, const char *client,
(host != NULL && client == NULL) ||
(host == NULL && client != NULL) );
/* special case for root zone */
if (strcmp(zone, ".") == 0)
isroot = ISC_TRUE;
/* if the requested zone is "unsafe", return error */
if (is_safe(zone) != ISC_TRUE)
if (!isroot && !is_safe(zone))
return (ISC_R_FAILURE);
/* if host was passed, verify that it is safe */
if ((host != NULL) && (is_safe(host) != ISC_TRUE) )
if (host != NULL && !is_safe(host))
return (ISC_R_FAILURE);
/* if host was passed, verify that it is safe */
if ((client != NULL) && (is_safe(client) != ISC_TRUE) )
/* if client was passed, verify that it is safe */
if (client != NULL && !is_safe(client))
return (ISC_R_FAILURE);
/* Determine how much memory the split up string will require */
@@ -302,8 +304,11 @@ create_path(const char *zone, const char *host, const char *client,
strcpy(tmpPath, cd->basedir);
/* add zone name - parsed properly */
if ((result = create_path_helper(tmpPath, zone, cd)) != ISC_R_SUCCESS)
goto cleanup_mem;
if (!isroot) {
result = create_path_helper(tmpPath, zone, cd);
if (result != ISC_R_SUCCESS)
goto cleanup_mem;
}
/*
* When neither client or host is passed we are building a
@@ -356,7 +361,7 @@ create_path(const char *zone, const char *host, const char *client,
isc_mem_free(ns_g_mctx, tmpPath);
/* free tmpPath memory */
return result;
return (result);
}
static isc_result_t
@@ -525,7 +530,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
"Filesystem driver: "
"%s could not be parsed properly",
tmp);
return ISC_R_FAILURE;
return (ISC_R_FAILURE);
}
/* replace separator char with NULL to split string */
@@ -540,7 +545,7 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
"Filesystem driver: "
"%s could not be parsed properly",
tmp);
return ISC_R_FAILURE;
return (ISC_R_FAILURE);
}
/* replace separator char with NULL to split string */
@@ -578,10 +583,10 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
/* if error, return error right away */
if (result != ISC_R_SUCCESS)
return result;
return (result);
} /* end of while loop */
return result;
return (result);
}
/*
@@ -621,7 +626,7 @@ fs_allowzonexfr(void *driverarg, void *dbdata, const char *name,
complete_AXFR:
isc_mem_free(ns_g_mctx, path);
return result;
return (result);
}
static isc_result_t
@@ -740,7 +745,7 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
if (basepath != NULL)
isc_mem_free(ns_g_mctx, basepath);
return result;
return (result);
}
static isc_result_t
@@ -779,7 +784,7 @@ fs_findzone(void *driverarg, void *dbdata, const char *name)
complete_FZ:
isc_mem_free(ns_g_mctx, path);
return result;
return (result);
}
static isc_result_t
@@ -851,7 +856,7 @@ fs_lookup(const char *zone, const char *name, void *driverarg,
complete_lkup:
isc_mem_free(ns_g_mctx, path);
return result;
return (result);
}
static isc_result_t
@@ -947,7 +952,7 @@ fs_create(const char *dlzname, unsigned int argc, char *argv[],
*dbdata = cd;
/* return success */
return(ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
/* handle no memory error */
no_mem:
@@ -1035,7 +1040,7 @@ dlz_fs_init(void)
result = ISC_R_UNEXPECTED;
}
return result;
return (result);
}
/*%