[PATCH] unitialized value in sexp.c

Ian Peters itp@ximian.com
11 Mar 2003 23:38:21 -0500


--=-TWdnmdrCu7O1q5nmZscQ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Running a program that uses GnuTLS in valgrind
(http://developer.kde.org/~sewardj/) found the following potential
error:

==6673== Conditional jump or move depends on uninitialised value(s)
==6673==    at 0x4045C832: gcry_mpi_print (mpicoder.c:493)
==6673==    by 0x404393AB: sexp_sscan (sexp.c:1033)
==6673==    by 0x404397D7: gcry_sexp_build (sexp.c:1177)

This tiny patch appears to fix the issue (and be the correct thing to
do).

No other warnings or errors were generated, although I can't tell you
what kind of code coverage there was.

Ian


--=-TWdnmdrCu7O1q5nmZscQ
Content-Disposition: attachment; filename=libgcrypt-1.1.12-sexp-valgrind-error.patch
Content-Type: text/x-patch; name=libgcrypt-1.1.12-sexp-valgrind-error.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -Nru -x '*~' -x '*.o' -x '*.orig' -x '*.rej' libgcrypt-1.1.12.orig/src/sexp.c libgcrypt-1.1.12/src/sexp.c
--- libgcrypt-1.1.12.orig/src/sexp.c	2003-01-15 05:16:52.000000000 -0500
+++ libgcrypt-1.1.12/src/sexp.c	2003-03-11 23:28:48.000000000 -0500
@@ -1028,7 +1028,7 @@
 	else if ( percent ) {
 	    if ( *p == 'm' ) { /* insert an MPI */
 		GCRY_MPI m = va_arg (arg_ptr, GCRY_MPI);
-		size_t nm;
+		size_t nm = 0;
 
 		if ( gcry_mpi_print( GCRYMPI_FMT_STD, NULL, &nm, m ) )
 		    BUG ();

--=-TWdnmdrCu7O1q5nmZscQ--