PERFORCE change 179632 for review

Julien Laffaye jlaffaye at FreeBSD.org
Tue Jun 15 01:20:25 UTC 2010


http://p4web.freebsd.org/@@179632?ac=10

Change 179632 by jlaffaye at jlaffaye-chulak on 2010/06/15 01:20:08

	NULL terminate the buffer returned by unpack_to_buffer().
	This fix a bug in read_plist_from_buffer() caused by strlcpy() 
	which try to read outside of the buffer range (spotted by valgrind).

Affected files ...

.. //depot/projects/soc2010/pkg_complete/lib/libpkg/file.c#6 edit

Differences ...

==== //depot/projects/soc2010/pkg_complete/lib/libpkg/file.c#6 (text+ko) ====

@@ -401,7 +401,7 @@
 					errno = EINVAL;
 				else {
 
-					*buf = malloc(sizeof(char)*buf_size);
+					*buf = malloc(buf_size+1);
 
 					if (*buf == NULL) {
 						error = strerror(errno);
@@ -411,6 +411,8 @@
 						r = archive_read_data(archive,
 						    *buf, buf_size);
 
+						(*buf)[buf_size] = 0;
+
 						if (r != buf_size) {
 							error = archive_error_string(archive);
 							buf_size = 0;


More information about the p4-projects mailing list