diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-05 11:34:44 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-05 11:34:44 +0000 |
commit | 4a6acac1becf0af0be0deb9fc17d4cdcf8595071 (patch) | |
tree | ff45109338a72998cd29148605a2c3dad10cfa37 /lib/sockunion.c | |
parent | 0f32dcb7962d74cfc2289974d58c4c8b4794167d (diff) | |
download | quagga-4a6acac1becf0af0be0deb9fc17d4cdcf8595071.tar.bz2 quagga-4a6acac1becf0af0be0deb9fc17d4cdcf8595071.tar.xz |
Tighten SU_ADDRSTRLEN and sockunion2str() in lib/sockunion.c/.h
Added confirms and assert for SU_ADDRSTRLEN in sockunion.h and in
sockunion2str().
Diffstat (limited to 'lib/sockunion.c')
-rw-r--r-- | lib/sockunion.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c index 054b17e6..d1fdb189 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -164,9 +164,16 @@ str2sockunion (const char *str, union sockunion *su) return -1; } +/*------------------------------------------------------------------------------ + * Construct string for sockunion IP address. + * + * Requires buffer of at least SU_ADDRSTRLEN characters. + */ const char * sockunion2str (union sockunion *su, char *buf, size_t len) { + assert(len >= SU_ADDRSTRLEN) ; + if (su->sa.sa_family == AF_INET) return inet_ntop (AF_INET, &su->sin.sin_addr, buf, len); #ifdef HAVE_IPV6 |