void *request_data_reference(REQUEST *request,
void *unique_ptr, int unique_int);
int rad_copy_string(char *dst, const char *src);
+int rad_copy_string_bare(char *dst, const char *src);
int rad_copy_variable(char *dst, const char *from);
int rad_pps(int *past, int *present, time_t *then,
struct timeval *now);
return length;
}
+/*
+ * Copy a quoted string but without the quotes. The length
+ * returned is the number of chars written; the number of
+ * characters consumed is 2 more than this.
+ */
+int rad_copy_string_bare(char *to, const char *from)
+{
+ int length = 0;
+ char quote = *from;
+
+ from++;
+ while (*from && (*from != quote)) {
+ if (*from == '\\') {
+ *(to++) = *(from++);
+ length++;
+ }
+ *(to++) = *(from++);
+ length++;
+ }
+
+ if (*from != quote) return -1; /* not properly quoted */
+
+ *to = '\0';
+
+ return length;
+}
+
/*
* Copy a %{} string.
switch (*from) {
case '"':
case '\'':
- length = rad_copy_string(to, from);
+ length = rad_copy_string_bare(to, from);
if (length < 0) {
radlog(L_ERR, "rad_expand_xlat: Invalid string passed as argument");
return -1;
}
- from += length;
+ from += length+2;
to += length;
break;