library/src/blockclass/BP-BlockClass.cc
// Appends insert data to a delayed insert string.  Allows for multiple
// inserts to be done very quickly.
Appends insert data to a delayed insert string.  Allows for multiple
inserts to be done very quickly.
Appends insert data to a delayed insert string . Allows for multiple inserts to be done very quickly .
BP_ERROR_T Block::insertWebJITExpressionMatchDelayed(size_t group_id, size_t test_id, size_t result_id, char * match_val, size_t match_len)
{
	BP_StringUtils * builder = new BP_StringUtils(NULL);
	if(this->jit_delayed_insert_sql)
		builder->BuildString(this->jit_delayed_insert_sql);
	if(this->jit_delayed_insert_sql)
		tq_free(this->tq, this->jit_delayed_insert_sql);
	this->jit_delayed_insert_sql = NULL;
	char group_id_varchar[64]  = {0};
	char test_id_varchar[64]   = {0};
	char result_id_varchar[64] = {0};
	char match_len_varchar[64] = {0};
	sprintf((char *) &group_id_varchar,  "%u", group_id);
	sprintf((char *) &test_id_varchar,   "%u", test_id);
	sprintf((char *) &result_id_varchar, "%u", result_id);
	sprintf((char *) &match_len_varchar, "%u", match_len);
	char * match = BP_BufferToHexString(match_val, match_len);
	builder->BuildString("( ");
	builder->BuildString((char *) &group_id_varchar);
	builder->BuildString(",");
	builder->BuildString((char *) &test_id_varchar);
	builder->BuildString(",");
	builder->BuildString((char *) &result_id_varchar);
	builder->BuildString(",sha1(0x");
	builder->BuildString((char *) match);
	builder->BuildString((char *) ")");
	builder->BuildString(",0x");
	builder->BuildString((char *) match);
	builder->BuildString("),");
	this->jit_delayed_insert_sql = tq_strdup(this->tq, builder->build_str, BPLN);
	tq_free(this->tq, match);
	delete builder;
	return ERR_SUCCESS;
}
BP_ERROR_T Block :: insertWebJITExpressionMatchDelayed ( size_t group_id , size_t test_id , size_t result_id , char * match_val , size_t match_len ) { BP_StringUtils * builder = new BP_StringUtils ( NULL ) ; if ( this -> jit_delayed_insert_sql ) builder -> BuildString ( this -> jit_delayed_insert_sql ) ; if ( this -> jit_delayed_insert_sql ) tq_free ( this -> tq , this -> jit_delayed_insert_sql ) ; this -> jit_delayed_insert_sql = NULL ; char group_id_varchar [ 64 ] = { 0 } ; char test_id_varchar [ 64 ] = { 0 } ; char result_id_varchar [ 64 ] = { 0 } ; char match_len_varchar [ 64 ] = { 0 } ; sprintf ( ( char * ) & group_id_varchar , " " , group_id ) ; sprintf ( ( char * ) & test_id_varchar , " " , test_id ) ; sprintf ( ( char * ) & result_id_varchar , " " , result_id ) ; sprintf ( ( char * ) & match_len_varchar , " " , match_len ) ; char * match = BP_BufferToHexString ( match_val , match_len ) ; builder -> BuildString ( " " ) ; builder -> BuildString ( ( char * ) & group_id_varchar ) ; builder -> BuildString ( " " ) ; builder -> BuildString ( ( char * ) & test_id_varchar ) ; builder -> BuildString ( " " ) ; builder -> BuildString ( ( char * ) & result_id_varchar ) ; builder -> BuildString ( " " ) ; builder -> BuildString ( ( char * ) match ) ; builder -> BuildString ( ( char * ) " " ) ; builder -> BuildString ( " " ) ; builder -> BuildString ( ( char * ) match ) ; builder -> BuildString ( " " ) ; this -> jit_delayed_insert_sql = tq_strdup ( this -> tq , builder -> build_str , BPLN ) ; tq_free ( this -> tq , match ) ; delete builder ; return ERR_SUCCESS ; }
Appends insert data to a delayed insert string.
Appends insert data to a delayed insert string .
// create a new builder // set the initial string if necessary // destroy the data at this point // nullify the delayed insert sql // set ids // embed data // convert match to hex for insert protection (prevents sqli) // add a set entry // duplicate builder as delayed insert set // destroy the match // return indicating success