[2/2] osf: fixed /proc reading bug
Patrick McHardy
kaber@trash.net
Sat Aug 21 23:30:17 CEST 2004
Evgeniy Polyakov wrote:
>Fixed buffer overflow when reading rules from /proc file.
>
How is this supposed to fix it ?
log("%s [%s]", f->genre, f->details);
- count += sprintf(buf+count, "%s - %s[%s] : %s",
+ err = snprintf(buf+count, __count-count, "%s - %s[%s] : %s",
f->genre, f->version,
f->subtype, f->details);
-
+ if (err < 0)
+ break;
+ else
+ count += err;
if (f->opt_num)
{
loga(" OPT: ");
snprintf returns the number of characters written if n <= limit, otherwise
the number of characters that would have been generated for the given input,
but never < 0. You can also use vscnprintf to get the real number of bytes
written.
Regards
Patrick
More information about the netfilter-devel
mailing list