From: simon Date: Sun, 2 Oct 2011 14:03:47 +0000 (+0000) Subject: Another utility function, to free a string containing sensitive data. X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/12b9e82db464e4e8b188b960e7439bd66a3eb03a Another utility function, to free a string containing sensitive data. git-svn-id: svn://svn.tartarus.org/sgt/putty@9319 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/misc.c b/misc.c index 8a9c7b11..636ca9f3 100644 --- a/misc.c +++ b/misc.c @@ -200,6 +200,14 @@ char *dupcat(const char *s1, ...) return p; } +void burnstr(char *string) /* sfree(str), only clear it first */ +{ + if (string) { + memset(string, 0, strlen(string)); + sfree(string); + } +} + /* * Do an sprintf(), but into a custom-allocated buffer. * diff --git a/misc.h b/misc.h index 49942aa5..9675e961 100644 --- a/misc.h +++ b/misc.h @@ -28,6 +28,7 @@ char *dupstr(const char *s); char *dupcat(const char *s1, ...); char *dupprintf(const char *fmt, ...); char *dupvprintf(const char *fmt, va_list ap); +void burnstr(char *string); char *fgetline(FILE *fp);