]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Another utility function, to free a string containing sensitive data.
authorSimon Tatham <anakin@pobox.com>
Sun, 2 Oct 2011 14:03:47 +0000 (14:03 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 2 Oct 2011 14:03:47 +0000 (14:03 +0000)
[originally from svn r9319]

misc.c
misc.h

diff --git a/misc.c b/misc.c
index 8a9c7b11ed3ea1759c878ae16eaea9ab737c3d79..636ca9f39f003a60901ea4f2495c0cdf027775af 100644 (file)
--- 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 49942aa5e0f0b3afaedac4ff33c18f49238a4e48..9675e96188798448c593a96abca70ad0fc7d26aa 100644 (file)
--- 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);