bug in token.c ?
Oliver Schröder
oliver.schroeder at versatel.de
Mon Jul 25 10:45:08 CEST 2011
Hello List,
I believe I found a bug in token.c, more precisely in
static FR_TOKEN getthing(...)
The exact point is the part handling backslahes:
--- cut ---
if (quote && (*p == '\\')) {
p++;
switch(*p) {
case 'r':
*s++ = '\r';
break;
case 'n':
*s++ = '\n';
break;
case 't':
*s++ = '\t';
break;
case '\0':
*s++ = '\\';
p--; /* force EOS */
break;
default:
if (*p >= '0' && *p <= '9' &&
sscanf(p, "%3o", &x) == 1) {
*s++ = x;
p += 2;
} else
*s++ = *p;
break;
}
p++;
continue;
}
--- cut ---
This piece of code removes all backslashes from the input string, which
gives incorrect results when parsing strings for regular expressions
with excaped characters. At a first glance, the fix is easy:
--- cut ---
default:
if (*p >= '0' && *p <= '9' &&
sscanf(p, "%3o", &x) == 1) {
*s++ = x;
p += 2;
} else {
*s++ = '\\'; /* copy the '\' too */
*s++ = *p;
}
break;
--- cut ---
which solves the problem.
On the other hand, I'm not sure if it breaks anything else. Is there a
reason to remove backslashes on purpose? Or is this really a bug?
Regards,
Oliver Schröder
More information about the Freeradius-Devel
mailing list