svn rev #21766: trunk/src/lib/rpc/

raeburn@MIT.EDU raeburn at MIT.EDU
Tue Jan 20 18:49:28 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=21766
Commit By: raeburn
Log Message:
When encoding, and compiling with -DUSE_VALGRIND, explicitly get valgrind to check the inputs.


Changed Files:
U   trunk/src/lib/rpc/xdr.c
Modified: trunk/src/lib/rpc/xdr.c
===================================================================
--- trunk/src/lib/rpc/xdr.c	2009-01-20 22:52:29 UTC (rev 21765)
+++ trunk/src/lib/rpc/xdr.c	2009-01-20 23:49:08 UTC (rev 21766)
@@ -54,6 +54,10 @@
 #define XDR_TRUE	((long) 1)
 #define LASTUNSIGNED	((u_int) 0-1)
 
+#ifdef USE_VALGRIND
+#include <valgrind/memcheck.h>
+#endif
+
 /*
  * for unit alignment
  */
@@ -93,6 +97,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*ip);
+#endif
 		if (*ip > 0x7fffffffL || *ip < -0x7fffffffL - 1L)
 			return (FALSE);
 
@@ -126,6 +133,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*up);
+#endif
 		if (*up > 0xffffffffUL)
 			return (FALSE);
 
@@ -158,6 +168,9 @@
 
 	switch (xdrs->x_op) {
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*lp);
+#endif
 		if (*lp > 0x7fffffffL || *lp < -0x7fffffffL - 1L)
 			return (FALSE);
 
@@ -181,6 +194,9 @@
 
 	switch (xdrs->x_op) {
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*ulp);
+#endif
 		if (*ulp > 0xffffffffUL)
 			return (FALSE);
 
@@ -206,6 +222,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*sp);
+#endif
 		l = (long) *sp;
 		return (XDR_PUTLONG(xdrs, &l));
 
@@ -236,6 +255,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*usp);
+#endif
 		l = (u_long) *usp;
 		return (XDR_PUTLONG(xdrs, (long *) &l));
 
@@ -261,6 +283,15 @@
 {
 	int i;
 
+#ifdef USE_VALGRIND
+	switch (xdrs->x_op) {
+	case XDR_ENCODE:
+		VALGRIND_CHECK_DEFINED(*cp);
+		break;
+	default:
+		break;
+	}
+#endif
 	i = (*cp);
 	if (!xdr_int(xdrs, &i)) {
 		return (FALSE);
@@ -277,6 +308,15 @@
 {
 	u_int u;
 
+#ifdef USE_VALGRIND
+	switch (xdrs->x_op) {
+	case XDR_ENCODE:
+		VALGRIND_CHECK_DEFINED(*cp);
+		break;
+	default:
+		break;
+	}
+#endif
 	u = (*cp);
 	if (!xdr_u_int(xdrs, &u)) {
 		return (FALSE);
@@ -296,6 +336,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*bp);
+#endif
 		lb = *bp ? XDR_TRUE : XDR_FALSE;
 		return (XDR_PUTLONG(xdrs, &lb));
 
@@ -324,6 +367,15 @@
 	/*
 	 * enums are treated as ints
 	 */
+#ifdef USE_VALGRIND
+	switch (xdrs->x_op) {
+	case XDR_ENCODE:
+		VALGRIND_CHECK_DEFINED(*ep);
+		break;
+	default:
+		break;
+	}
+#endif
 	if (sizeof (enum sizecheck) == sizeof (long)) {
 		return (xdr_long(xdrs, (long *)ep));
 	} else if (sizeof (enum sizecheck) == sizeof (int)) {
@@ -373,6 +425,9 @@
 	}
 
 	if (xdrs->x_op == XDR_ENCODE) {
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_READABLE((volatile void *)cp, cnt);
+#endif
 		if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
 			return (FALSE);
 		}
@@ -463,6 +518,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*ip);
+#endif
 		l = *ip;
 		return (xdr_long(xdrs, &l));    
 
@@ -487,6 +545,9 @@
 	switch (xdrs->x_op) {
 
 	case XDR_ENCODE:
+#ifdef USE_VALGRIND
+		VALGRIND_CHECK_DEFINED(*up);
+#endif
 		ul = *up;
 		return (xdr_u_long(xdrs, &ul));    
 




More information about the cvs-krb5 mailing list