* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
- * Copyright 2002 The FreeRADIUS server project
+ * Copyright 2002,2006 The FreeRADIUS server project
* Copyright 2002 Kostas Kalevras <kkalev@noc.ntua.gr>
*/
-#include <freeradius-devel/autoconf.h>
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+
+#include <freeradius-devel/radiusd.h>
+#include <freeradius-devel/modules.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
-#include <freeradius-devel/radiusd.h>
-#include <freeradius-devel/modules.h>
-
#define RLM_REGEX_INPACKET 0
#define RLM_REGEX_INCONFIG 1
#define RLM_REGEX_INREPLY 2
#define RLM_REGEX_INPROXY 3
#define RLM_REGEX_INPROXYREPLY 4
-static const char rcsid[] = "$Id$";
-
typedef struct rlm_attr_rewrite_t {
char *attribute; /* The attribute to search for */
int attr_num; /* The attribute number */
DEBUG2("rlm_attr_rewrite: regcomp() returned error: %s",err_msg);
return ret;
}
-
+
if ((attr_vp->type == PW_TYPE_IPADDR) &&
(attr_vp->vp_strvalue[0] == '\0')) {
- inet_ntop(AF_INET, &(attr_vp->lvalue),
- attr_vp->vp_strvalue,
- sizeof(attr_vp->vp_strvalue));
+ inet_ntop(AF_INET, &(attr_vp->vp_ipaddr),
+ attr_vp->vp_strvalue,
+ sizeof(attr_vp->vp_strvalue));
}
ptr = new_str;
return ret;
}
- strncpy(ptr, ptr2,len);
+ memcpy(ptr, ptr2,len);
ptr += len;
+ *ptr = '\0';
ptr2 += pmatch[0].rm_eo;
if (i == 0){
return ret;
}
if (replace_len){
- strncpy(ptr, replace_STR, replace_len);
+ memcpy(ptr, replace_STR, replace_len);
ptr += replace_len;
+ *ptr = '\0';
}
}
regfree(&preg);
data->attribute, attr_vp->vp_strvalue);
return ret;
}
- strncpy(ptr, ptr2, len);
+ memcpy(ptr, ptr2, len);
+ ptr[len] = '\0';
DEBUG2("rlm_attr_rewrite: Changed value for attribute %s from '%s' to '%s'",
data->attribute, attr_vp->vp_strvalue, new_str);
{
rlm_attr_rewrite_t *data = (rlm_attr_rewrite_t *) instance;
- if (data->attribute)
- free(data->attribute);
- if (data->search)
- free(data->search);
- if (data->replace)
- free(data->replace);
if (data->name)
free(data->name);