aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-06-23 15:26:55 +0200
committerMattias Andrée <maandree@kth.se>2023-06-23 15:26:55 +0200
commit43d7766178e6696d009397d0e034b9cdaa9fa7da (patch)
tree34a6735921264d47c69110f601bc24cd5227fb76
parentImplement keyfile forwarding (diff)
downloadkey2root-43d7766178e6696d009397d0e034b9cdaa9fa7da.tar.gz
key2root-43d7766178e6696d009397d0e034b9cdaa9fa7da.tar.bz2
key2root-43d7766178e6696d009397d0e034b9cdaa9fa7da.tar.xz
Fix support for NUL bytes in the keyfile
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--key2root-addkey.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/key2root-addkey.c b/key2root-addkey.c
index c9f62b3..5b3f1ee 100644
--- a/key2root-addkey.c
+++ b/key2root-addkey.c
@@ -164,6 +164,7 @@ main(int argc, char *argv[])
#define HASH_PREFIX "$6$"
char generated_parameters[sizeof(HASH_PREFIX"$") + 16];
ssize_t r;
+ size_t i;
ARGBEGIN {
case 'r':
@@ -228,6 +229,9 @@ main(int argc, char *argv[])
}
key_len += (size_t)r;
}
+ for (i = 0; i < key_len; i++)
+ if (!key[i])
+ key[i] = 255;
key[key_len] = '\0';
hash = crypt(key, parameters);
if (!hash)