From: Gianni Tedesco Subject: [PATCH]: xl: poison data objects in auto-generated destructors Date: Fri, 20 Aug 2010 15:49:51 +0100 Message-ID: <1282315791.3731.60.camel@qabil.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen Devel Cc: Ian Campbell , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Increase the probability of blowing up badly up during any use-after-destroy scenarios. Signed-off-by: Gianni Tedesco diff -r f68726cdf357 tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Thu Aug 19 18:24:12 2010 +0100 +++ b/tools/libxl/gentypes.py Fri Aug 20 15:51:35 2010 +0100 @@ -145,15 +145,19 @@ if __name__ == '__main__': #include #include +#include #include "libxl.h" +#define LIBXL_DTOR_POISON 0xa5 + """ % " ".join(sys.argv)) for ty in [t for t in types if t.destructor_fn is not None and t.autogenerate_destructor]: f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename)) f.write("{\n") f.write(libxl_C_type_destroy(ty, "p", True)) + f.write("\tmemset(p, LIBXL_DTOR_POISON, sizeof(*p));\n") f.write("}\n") f.write("\n") f.close()