char unescaped[sizeof(output_buff)];
request_t *request;
fr_sbuff_t line;
- fr_sbuff_t out = FR_SBUFF_OUT(output_buff, sizeof(output_buff));
+ fr_sbuff_t out;
static fr_sbuff_escape_rules_t unprintables = {
.name = "unprintables",
* Ignore blank lines and comments
*/
fr_sbuff_adv_past_whitespace(&line, SIZE_MAX, NULL);
-
if (*fr_sbuff_current(&line) < ' ') continue;
if (fr_sbuff_is_char(&line, '#')) continue;
+ /*
+ * Look for "match", as it needs the output_buffer to be left alone.
+ */
+ if (fr_sbuff_adv_past_str_literal(&line, "match ") > 0) {
+ size_t output_len = strlen(output_buff);
+
+ if (!fr_sbuff_is_str(&line, output_buff, output_len) || (output_len != fr_sbuff_remaining(&line))) {
+ fprintf(stderr, "Mismatch at %s[%u]\n\tgot : %s (%zu)\n\texpected : %s (%zu)\n",
+ filename, lineno, output_buff, output_len, fr_sbuff_current(&line), fr_sbuff_remaining(&line));
+ TALLOC_FREE(request);
+ return false;
+ }
+ continue;
+ }
+
+ /*
+ * The rest of the keywords create output.
+ */
+ output_buff[0] = '\0';
+ out = FR_SBUFF_OUT(output_buff, sizeof(output_buff));
+
/*
* Look for "xlat"
*/
if (len < 0) {
char const *err = fr_strerror();
talloc_free(xlat_ctx);
- FR_SBUFF_IN_SPRINTF_RETURN(&out, "ERROR expanding xlat: %s", *err ? err : "no error provided");
+ fr_sbuff_in_sprintf(&out, "ERROR expanding xlat: %s", *err ? err : "no error provided");
continue;
}
continue;
}
- /*
- * Look for "match".
- */
- if (fr_sbuff_adv_past_str_literal(&line, "match ") > 0) {
- size_t output_len = strlen(output_buff);
- if (!fr_sbuff_is_str(&line, output_buff, output_len) && (output_len != fr_sbuff_remaining(&line))) {
- fprintf(stderr, "Mismatch at %s[%u]\n\tgot : %s (%zu)\n\texpected : %s (%zu)\n",
- filename, lineno, output_buff, output_len, fr_sbuff_current(&line), fr_sbuff_remaining(&line));
- TALLOC_FREE(request);
- return false;
- }
- continue;
- }
-
fprintf(stderr, "Unknown keyword in %s[%d]\n", filename, lineno);
TALLOC_FREE(request);
return false;
# this is "foo" + PRINTABLE version of the packet authentication vector
-xlat_expr "foo%{radius.packet.vector:}"
-match foo\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
+xlat_expr "foo%{bin:000000}"
+match foo\000\000\000
xlat_expr 1 && 2
match 2
# This just casts the octets to 'string', without
# any escaping.
#
-xlat_expr "foo" + (string)%{radius.packet.vector:}
-match foo\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
+xlat_expr "foo" + (string)%{bin:0x0001020304}
+match foo\000\001\002\003\004
+
# string + octets gets promoted to octets
-xlat_expr "foo" + 0x00000000000000000000000000000000
-match 0x666f6f00000000000000000000000000000000
+xlat_expr "foo" + %{bin:0x0001020304}
+match 0x666f6f0001020304
# no escaping!
xlat_expr 'foo%{Packet-Authentication-Vector}'