If USE_VALGRIND, check readability of byte string before copying
authorKen Raeburn <raeburn@mit.edu>
Thu, 22 Jan 2009 06:30:08 +0000 (06:30 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 22 Jan 2009 06:30:08 +0000 (06:30 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21774 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/asn1buf.c

index b8efabaca4e1996c57c524cd1353721909af3650..71ad03b2460d829ca98363eacd1dbb3e9c4b2938 100644 (file)
 #include <stdio.h>
 #include "asn1_get.h"
 
+#ifdef USE_VALGRIND
+#include <valgrind/memcheck.h>
+#else
+#define VALGRIND_CHECK_READABLE(PTR,SIZE) ((void)0)
+#endif
+
 #if !defined(__GNUC__) || defined(CONFIG_SMALL)
 /* Declare private procedures as static if they're not used for inline
    expansion of other stuff elsewhere.  */
@@ -181,6 +187,7 @@ asn1buf_insert_bytestring(asn1buf *buf, const unsigned int len, const void *sv)
 
     retval = asn1buf_ensure_space(buf,len);
     if (retval) return retval;
+    VALGRIND_CHECK_READABLE(sv, len);
     for (length=1; length<=len; length++,(buf->next)++)
         *(buf->next) = (s[len-length]);
     return 0;