sbspace() / sbappendaddr() problem
vanhu_bsd at zeninc.net
Thu Sep 1 07:54:51 GMT 2005
I have some reccurent problems with PFKey interafce for a while, whith
While tracking down the problem, I found that a test goes wrong in
sbappendaddr(), in kern_uipc_socket2.c, because the "space" variable
(an int) gets "bigger" than the result of sbspace(sb), which shlould
After having a deeper look at sbspace() macro, I noticed that there
are some potential cast/sign problems with this macro (this is
specified in the comments of the macro).
So I wrote a new version of the macro, which should avoir all
#define sbspace(sb) \
(ulmin( ( (sb)->sb_hiwat > (sb)->sb_cc ? (sb)->sb_hiwat - (sb)->sb_cc : 0), \
(sb)->sb_mbmax > (sb)->sb_mbcnt ? (sb)->sb_mbmax - (sb)->sb_mbcnt : 0)))
Then I set up the type of "space" variable in sbappendaddr() as
u_long, and I have no more problems for now.
But as this function and this macro are used on some other parts of
the kernel, I don't know if I solved all problems, or if I generated
new problems elsewhere while solving one.
Does someone have any comments on this new sbspace() ?
NETASQ - Secure Internet Connectivity
More information about the freebsd-net