changeset 38:f5c024aa1dc5 stable-0-5-9

more valgrind fixes
author carl
date Sun, 12 Aug 2007 14:30:15 -0700
parents ddfb25318812
children 2ad7ef0a3c4f
files ChangeLog NEWS configure.in src/pst2ldif.cpp src/readpst.c
diffstat 5 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 10 08:06:13 2007 -0700
+++ b/ChangeLog	Sun Aug 12 14:30:15 2007 -0700
@@ -1,3 +1,8 @@
+LibPST 0.5.9 (2007-08-12)
+===============================
+
+        * fix more valgrind errors.
+
 LibPST 0.5.8 (2007-08-10)
 ===============================
 
--- a/NEWS	Fri Aug 10 08:06:13 2007 -0700
+++ b/NEWS	Sun Aug 12 14:30:15 2007 -0700
@@ -1,5 +1,7 @@
     $Id$
 
+0.5.9 2007-08-12 fix more valgrind errors, pst2ldif wrote undefined data
+0.5.8 2007-08-10 lzfu_decompress/base64_encode encoded random data into attachment
 0.5.7 2007-08-09 fix valgrind errors, using uninitialized data
 0.5.6 2007-07-15 handle small pst files, better decoding of 7c blocks
 0.5.5 2007-07-10 merge changes from Joe Nahmias version
--- a/configure.in	Fri Aug 10 08:06:13 2007 -0700
+++ b/configure.in	Sun Aug 12 14:30:15 2007 -0700
@@ -1,7 +1,7 @@
 AC_INIT(configure.in)
 
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libpst,0.5.8)
+AM_INIT_AUTOMAKE(libpst,0.5.9)
 AC_PATH_PROGS(BASH, bash)
 
 AC_LANG_CPLUSPLUS
--- a/src/pst2ldif.cpp	Fri Aug 10 08:06:13 2007 -0700
+++ b/src/pst2ldif.cpp	Sun Aug 12 14:30:15 2007 -0700
@@ -556,25 +556,26 @@
 	else {
 
 		// calculate space required to escape all the following characters
-		x = strlen(str) +(y=(chr_count(str, ',')*2) + (chr_count(str, '\\')*2) + (chr_count(str, ';')*2) + (chr_count(str, '\n')*2));
+		y = chr_count(str, '\\')
+		  + chr_count(str, ';');
 		z = chr_count(str, '\r');
 		if (y == 0 && z == 0)
 			// there isn't any extra space required
 			ret = str;
 		else {
-			buf = (char*) realloc(buf, x+1);
+			x = strlen(str) + y - z + 1; // don't forget room for the NUL
+			buf = (char*) realloc(buf, x);
 			a = str;
 			b = buf;
 			while (*a != '\0') {
 				switch(*a) {
-				 // case ',' :
 					case '\\':
 					case ';' :
-				 // case '\n':
 						*(b++)='\\';
 						*b=*a;
 					break;
-					case '\r':
+					case '\r':  // skip cr
+						b--;
 						break;
 					default:
 						*b=*a;
@@ -582,7 +583,7 @@
 				b++;
 				a++;
 			}
-			*b = '\0';
+			*b = '\0'; // NUL-terminate the string (buf)
 			ret = buf;
 		}
 	}
--- a/src/readpst.c	Fri Aug 10 08:06:13 2007 -0700
+++ b/src/readpst.c	Sun Aug 12 14:30:15 2007 -0700
@@ -822,11 +822,11 @@
 		  + chr_count(str, ';')
 		  + chr_count(str, '\n');
 		z = chr_count(str, '\r');
-		x = strlen(str) + y - z + 1; // don't forget room for the NUL
 		if (y == 0 && z == 0)
 			// there isn't any extra space required
 			ret = str;
 		else {
+			x = strlen(str) + y - z + 1; // don't forget room for the NUL
 			buf = (char*) realloc(buf, x);
 			a = str;
 			b = buf;