Commit 03a97678 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

use AC_MEMCPY instead of str[n]cpy

parent 7581e304
......@@ -123,7 +123,7 @@ rewrite_xmap_parse(
l = p - s - c;
filename = calloc( sizeof( char ), l + 1 );
strncpy( filename, s + c, l );
AC_MEMCPY( filename, s + c, l );
filename[ l ] = '\0';
map->lm_args = ( void * )fopen( filename, "r" );
......@@ -177,7 +177,7 @@ rewrite_xmap_parse(
*/
l = p - s - c;
url = calloc( sizeof( char ), l + 3 );
strncpy( url, s + c, l );
AC_MEMCPY( url, s + c, l );
url[ l ] = '\0';
/*
......@@ -270,7 +270,7 @@ rewrite_map_parse(
*/
l = p - string - 1;
s = calloc( sizeof( char ), l + 1 );
strncpy( s, string, l );
AC_MEMCPY( s, string, l );
s[ l ] = 0;
/*
......
......@@ -205,7 +205,7 @@ rewrite_rule_compile(
/* XXX Need to free stuff */
return REWRITE_ERR;
}
strncpy( buf, p + 2, l );
AC_MEMCPY( buf, p + 2, l );
buf[ l ] = '\0';
d = malloc( sizeof( int ) );
......
......@@ -91,7 +91,7 @@ rewrite_subst_compile(
if ( subs[ nsub - 1 ]->bv_val == NULL ) {
return NULL;
}
strncpy( subs[ nsub - 1 ]->bv_val, begin, l );
AC_MEMCPY( subs[ nsub - 1 ]->bv_val, begin, l );
subs[ nsub - 1 ]->bv_val[ l ] = '\0';
} else {
subs[ nsub - 1 ] = NULL;
......@@ -202,7 +202,7 @@ rewrite_subst_compile(
subs_len += l;
subs[ nsub ]->bv_len = l;
subs[ nsub ]->bv_val = malloc( l + 1 );
strncpy( subs[ nsub ]->bv_val, begin, l );
AC_MEMCPY( subs[ nsub ]->bv_val, begin, l );
subs[ nsub ]->bv_val[ l ] = '\0';
} else {
subs[ nsub ] = NULL;
......@@ -255,7 +255,7 @@ submatch_copy(
return REWRITE_ERR;
}
strncpy( val->bv_val, s, l );
AC_MEMCPY( val->bv_val, s, l );
val->bv_val[ l ] = '\0';
return REWRITE_SUCCESS;
......@@ -410,15 +410,18 @@ rewrite_subst_apply(
*/
for ( n = 0, cl = 0; n < subst->lt_num_submatch; n++ ) {
if ( subst->lt_subs[ n ] != NULL ) {
strcpy( res + cl, subst->lt_subs[ n ]->bv_val);
AC_MEMCPY( res + cl, subst->lt_subs[ n ]->bv_val,
subst->lt_subs[ n ]->bv_len );
cl += subst->lt_subs[ n ]->bv_len;
}
strcpy( res + cl, submatch[ n ].bv_val );
AC_MEMCPY( res + cl, submatch[ n ].bv_val,
submatch[ n ].bv_len );
cl += submatch[ n ].bv_len;
free( submatch[ n ].bv_val );
}
if ( subst->lt_subs[ n ] != NULL ) {
strcpy( res + cl, subst->lt_subs[ n ]->bv_val );
AC_MEMCPY( res + cl, subst->lt_subs[ n ]->bv_val,
subst->lt_subs[ n ]->bv_len );
}
val->bv_val = res;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment