debuggers.hg

changeset 22096:f77261710856

xl: poison data objects in auto-generated destructors

Increase the probability of blowing up badly up during any
use-after-destroy scenarios.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Gianni Tedesco <gianni.tedesco@citrix.com>
date Fri Aug 20 17:12:00 2010 +0100 (2010-08-20)
parents f68726cdf357
children 59ff5820534f
files tools/libxl/gentypes.py
line diff
     1.1 --- a/tools/libxl/gentypes.py	Thu Aug 19 18:24:12 2010 +0100
     1.2 +++ b/tools/libxl/gentypes.py	Fri Aug 20 17:12:00 2010 +0100
     1.3 @@ -145,15 +145,19 @@ if __name__ == '__main__':
     1.4  
     1.5  #include <stdint.h>
     1.6  #include <stdlib.h>
     1.7 +#include <string.h>
     1.8  
     1.9  #include "libxl.h"
    1.10  
    1.11 +#define LIBXL_DTOR_POISON 0xa5
    1.12 +
    1.13  """ % " ".join(sys.argv))
    1.14  
    1.15      for ty in [t for t in types if t.destructor_fn is not None and t.autogenerate_destructor]:
    1.16          f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename))
    1.17          f.write("{\n")
    1.18          f.write(libxl_C_type_destroy(ty, "p", True))
    1.19 +        f.write("\tmemset(p, LIBXL_DTOR_POISON, sizeof(*p));\n")
    1.20          f.write("}\n")
    1.21          f.write("\n")
    1.22      f.close()