Change ipsec_address() and ipsec_logsastr() functions to take two
authorae <ae@FreeBSD.org>
Sat, 18 Apr 2015 16:58:33 +0000 (16:58 +0000)
committerae <ae@FreeBSD.org>
Sat, 18 Apr 2015 16:58:33 +0000 (16:58 +0000)
commit070fa67a640029fe56143fee03e9640dc6dcf4be
treea9e1608200cc8668013854e1f3cceddd49bd64e6
parentf1962dadf4e79090ba39afcf11179184c3804e2f
Change ipsec_address() and ipsec_logsastr() functions to take two
additional arguments - buffer and size of this buffer.

ipsec_address() is used to convert sockaddr structure to presentation
format. The IPv6 part of this function returns pointer to the on-stack
buffer and at the moment when it will be used by caller, it becames
invalid. IPv4 version uses 4 static buffers and returns pointer to
new buffer each time when it called. But anyway it is still possible
to get corrupted data when several threads will use this function.

ipsec_logsastr() is used to format string about SA entry. It also
uses static buffer and has the same problem with concurrent threads.

To fix these problems add the buffer pointer and size of this
buffer to arguments. Now each caller will pass buffer and its size
to these functions. Also convert all places where these functions
are used (except disabled code).

And now ipsec_address() uses inet_ntop() function from libkern.

PR: 185996
Differential Revision: https://reviews.freebsd.org/D2321
Reviewed by: gnn
Sponsored by: Yandex LLC
sys/netipsec/ipsec.c
sys/netipsec/ipsec.h
sys/netipsec/ipsec_input.c
sys/netipsec/ipsec_output.c
sys/netipsec/xform_ah.c
sys/netipsec/xform_esp.c
sys/netipsec/xform_ipcomp.c