summaryrefslogtreecommitdiff
path: root/password.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-01-16 23:35:14 +0100
committeremersion <contact@emersion.fr>2019-01-17 09:53:23 +0100
commit0c7932a3af97dd0416dc2156dc82dfe0b8e3951d (patch)
treec986a2b2ceccfd340a6e844b2db3f9a533865387 /password.c
parent0c1f193083166ccc56107028bb8b59d7aa767732 (diff)
Move PAM into a child process
Diffstat (limited to 'password.c')
-rw-r--r--password.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/password.c b/password.c
index bef3481..43b6c75 100644
--- a/password.c
+++ b/password.c
@@ -11,13 +11,17 @@
#include "swaylock.h"
#include "unicode.h"
-void clear_password_buffer(struct swaylock_password *pw) {
+void clear_buffer(char *buf, size_t size) {
// Use volatile keyword so so compiler can't optimize this out.
- volatile char *buffer = pw->buffer;
+ volatile char *buffer = buf;
volatile char zero = '\0';
- for (size_t i = 0; i < sizeof(pw->buffer); ++i) {
+ for (size_t i = 0; i < size; ++i) {
buffer[i] = zero;
}
+}
+
+void clear_password_buffer(struct swaylock_password *pw) {
+ clear_buffer(pw->buffer, sizeof(pw->buffer));
pw->len = 0;
}