summaryrefslogtreecommitdiff
path: root/dlib/dlib.c
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-09-29 15:59:46 +0000
committercorvid <corvid@lavabit.com>2011-09-29 15:59:46 +0000
commit68c04d3d540722a7fc54d17d6c6571d77d6ff108 (patch)
tree3f706caf4799db02b6ede7c5d581da5741687206 /dlib/dlib.c
parent50ec4b32c530a6a4b48ff8b1bbe6be4d01c2f009 (diff)
password shredding
Justus had written a patch for this, but the list archive didn't want to disgorge it, so I wrote one.
Diffstat (limited to 'dlib/dlib.c')
-rw-r--r--dlib/dlib.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/dlib/dlib.c b/dlib/dlib.c
index f2ef2dd1..a3c59060 100644
--- a/dlib/dlib.c
+++ b/dlib/dlib.c
@@ -134,6 +134,15 @@ char *dStrstrip(char *s)
}
/*
+ * Clear the contents of the string
+ */
+void dStrshred(char *s)
+{
+ if (s)
+ memset(s, 0, strlen(s));
+}
+
+/*
* Return a new string of length 'len' filled with 'c' characters
*/
char *dStrnfill(size_t len, char c)
@@ -336,6 +345,15 @@ void dStr_truncate (Dstr *ds, int len)
}
/*
+ * Clear a Dstr.
+ */
+void dStr_shred (Dstr *ds)
+{
+ if (ds && ds->sz > 0)
+ memset(ds->str, '\0', ds->sz);
+}
+
+/*
* Erase a substring.
*/
void dStr_erase (Dstr *ds, int pos_0, int len)