* ip_conntrack_standalone / sprintf to buffer
@ 2005-05-24 5:50 Sven Schnelle
2005-06-11 15:57 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Sven Schnelle @ 2005-05-24 5:50 UTC (permalink / raw)
To: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 866 bytes --]
Hi,
found the following code snippet in ip_conntrack_standalone.c:145
in function conntrack_iterate():
-------------------000000------8<-----------------------------
newlen = print_conntrack(buffer + *len, hash->ctrack);
printk("len + newlen: %d maxlen: %d\n", *len + newlen, maxlen);
if (*len + newlen > maxlen)
return 1;
else *len += newlen;
-------------000000------------8<-----------------------------
print_conntrack() uses sprintf without length checking. And now i'm
wondering what happens if for example, maxlen=3072 and
len=3071. print_conntrack uses sprintf, writes beyond the end the buffer, and
after this the check (*len + newlen > maxlen) is done. Looks to me like
a bug.
Did i missed something?
Bye,
Sven.
--
"If you can't make it good, at least make it look good." Bill Gates on
the solid code base of Win9X
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: ip_conntrack_standalone / sprintf to buffer
2005-05-24 5:50 ip_conntrack_standalone / sprintf to buffer Sven Schnelle
@ 2005-06-11 15:57 ` Patrick McHardy
0 siblings, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2005-06-11 15:57 UTC (permalink / raw)
To: Sven Schnelle; +Cc: netfilter-devel
Sven Schnelle wrote:
> Hi,
>
> found the following code snippet in ip_conntrack_standalone.c:145
> in function conntrack_iterate():
> -------------------000000------8<-----------------------------
> newlen = print_conntrack(buffer + *len, hash->ctrack);
> printk("len + newlen: %d maxlen: %d\n", *len + newlen, maxlen);
> if (*len + newlen > maxlen)
> return 1;
> else *len += newlen;
> -------------000000------------8<-----------------------------
>
> print_conntrack() uses sprintf without length checking. And now i'm
> wondering what happens if for example, maxlen=3072 and
> len=3071. print_conntrack uses sprintf, writes beyond the end the buffer, and
> after this the check (*len + newlen > maxlen) is done. Looks to me like
> a bug.
>
> Did i missed something?
Yes, /proc reserves some space (I think its 1k) for writing over
the boundaries.
Regards
Patrick
^ permalink raw reply [flat|nested] 3+ messages in thread
* ip_conntrack_standalone / sprintf to buffer
@ 2005-05-24 5:50 Sven Schnelle
0 siblings, 0 replies; 3+ messages in thread
From: Sven Schnelle @ 2005-05-24 5:50 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 866 bytes --]
Hi,
found the following code snippet in ip_conntrack_standalone.c:145
in function conntrack_iterate():
-------------------000000------8<-----------------------------
newlen = print_conntrack(buffer + *len, hash->ctrack);
printk("len + newlen: %d maxlen: %d\n", *len + newlen, maxlen);
if (*len + newlen > maxlen)
return 1;
else *len += newlen;
-------------000000------------8<-----------------------------
print_conntrack() uses sprintf without length checking. And now i'm
wondering what happens if for example, maxlen=3072 and
len=3071. print_conntrack uses sprintf, writes beyond the end the buffer, and
after this the check (*len + newlen > maxlen) is done. Looks to me like
a bug.
Did i missed something?
Bye,
Sven.
--
"If you can't make it good, at least make it look good." Bill Gates on
the solid code base of Win9X
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-11 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-24 5:50 ip_conntrack_standalone / sprintf to buffer Sven Schnelle
2005-06-11 15:57 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2005-05-24 5:50 Sven Schnelle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.