Upgrade of the AlwaysHC patch so it can use unlimited subdomain depth.
// NEW FUNC BEGIN
/*
Extract the domain name
*/
static int d_ex(char *search, char *domain)
{
char mdot[]=".";
char *array[142];
int loop;
array[0]=strtok(search,mdot);
if(array[0]==NULL)
{
return 1;
}
for(loop=1;loop<142;loop++)
{
array[loop]=strtok(NULL,mdot);
if(array[loop]==NULL)
break;
}
if(loop<2) {
return 1;
}
snprintf(domain,255,"%s.%s",array[loop-2],array[loop-1]);
return 0;
}
// NEW FUNC END
AND YOUR PATCH MODIFIED HERE
// BEGIN PATCH
snprintf(str, sizeof(str),
"SELECT ttl, rdtype, rdata FROM %s WHERE "
"UPPER(name) = UPPER('%s') ", dbi->table, name);
//isc_mem_put(ns_g_mctx, canonname, strlen(name) *
2 + 1);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
char domain[255];
char non_cons_name[255];
strcpy(non_cons_name,name);
if(d_ex(non_cons_name,domain) != 0) {
return (ISC_R_FAILURE);
}
mysql_free_result(res);
snprintf(str, sizeof(str), "SELECT ttl, rdtype, rdata FROM %s WHERE UPPER(name) = UPPER('*.%s') ",dbi->table, domain);
result = maybe_reconnect(dbi);
if (result != ISC_R_SUCCESS)
return (result);
if( mysql_query(&dbi->conn, str) != 0 )
{
return (ISC_R_FAILURE);
}
res = mysql_store_result(&dbi->conn);
if (mysql_num_rows(res) == 0)
{
mysql_free_result(res);
return (ISC_R_NOTFOUND);
}
}
// END PATCH
mysql-bind-0.1\mysqldb.c - with the patch applied