#include <portable.h>
-#include <ac/string.h>
+#ifdef HAVE_PWD_H
#include <pwd.h>
+#endif
#include "rewrite-int.h"
#include "rewrite-map.h"
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" );
*/
l = p - s - c;
url = calloc( sizeof( char ), l + 3 );
- strncpy( url, s + c, l );
+ AC_MEMCPY( url, s + c, l );
url[ l ] = '\0';
/*
*/
p = strchr( url, '%' );
if ( p != NULL ) {
- memmove( p + 3, p + 1, strlen( p + 1 ) + 1 );
+ AC_MEMCPY( p + 3, p + 1, strlen( p + 1 ) + 1 );
p[ 1 ] = '2';
p[ 2 ] = '5';
}
for ( p = string, cnt = 1; p[ 0 ] != '\0' && cnt > 0; p++ ) {
if ( p[ 0 ] == REWRITE_SUBMATCH_ESCAPE ) {
/*
- * '\' marks the beginning of a new map
+ * '%' marks the beginning of a new map
*/
if ( p[ 1 ] == '{' ) {
cnt++;
/*
- * '\' followed by a digit may mark the beginning
+ * '%' followed by a digit may mark the beginning
* of an old map
*/
- } else if ( isdigit( p[ 1 ] ) && p[ 2 ] == '{' ) {
+ } else if ( isdigit( (unsigned char) p[ 1 ] ) && p[ 2 ] == '{' ) {
cnt++;
p++;
}
- p++;
+ if ( p[ 1 ] != '\0' )
+ p++;
} else if ( p[ 0 ] == '}' ) {
cnt--;
}
*/
l = p - string - 1;
s = calloc( sizeof( char ), l + 1 );
- strncpy( s, string, l );
+ AC_MEMCPY( s, string, l );
s[ l ] = 0;
/*
/*
* Check the syntax of the variable name
*/
- if ( !isalpha( p[ 0 ] ) ) {
+ if ( !isalpha( (unsigned char) p[ 0 ] ) ) {
free( s );
return NULL;
}
for ( p++; p[ 0 ] != '\0'; p++ ) {
- if ( !isalnum( p[ 0 ] ) ) {
+ if ( !isalnum( (unsigned char) p[ 0 ] ) ) {
free( s );
return NULL;
}
val->bv_len = 0;
switch ( map->lm_type ) {
+#ifdef HAVE_GETPWNAM
case REWRITE_MAP_XPWDMAP: {
struct passwd *pwd;
break;
}
+#endif /* HAVE_GETPWNAM*/
case REWRITE_MAP_XFILEMAP: {
char buf[1024];