From 0c7932a3af97dd0416dc2156dc82dfe0b8e3951d Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 16 Jan 2019 23:35:14 +0100 Subject: Move PAM into a child process --- password.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'password.c') 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; } -- cgit v1.2.3