Subject: CVS commit: src/lib/libutil
To: None <source-changes@NetBSD.org>
From: David Young <dyoung@netbsd.org>
List: source-changes
Date: 07/24/2007 08:45:46
Module Name:	src
Committed By:	dyoung
Date:		Tue Jul 24 08:45:45 UTC 2007

Modified Files:
	src/lib/libutil: sockaddr_snprintf.c

Log Message:
In sockaddr_snprintf(sbuf, len, fmt, sa), do not write the terminating
null character outside of the byte region [sbuf, sbuf + len).

1) If the length of the buffer is 0, do not write a null character
   at all.  Previously, sockaddr_snprintf() may have been able to
   overwrite sbuf[-1] if len was 0.

2) If the length of the buffer, len, is greater than 0, then write
   the null at sbuf[len - 1].  Previously, sockaddr_snprintf()
   wrote the null at buf[len - 1], where `buf' was a "cursor" that
   did not necessarily equal `sbuf', the start of the buffer.  Now,
   sockaddr_snprintf() always writes the null at sbuf[len - 1].


To generate a diff of this commit:
cvs rdiff -r1.7 -r1.8 src/lib/libutil/sockaddr_snprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.