From c192315eb5b4282d3d17ca79f4a07152e21c3fb4 Mon Sep 17 00:00:00 2001 From: Christian Hitz Date: Wed, 27 Mar 2024 13:02:50 +0100 Subject: [PATCH] rfbEncryptAndStorePasswd: fail if encryption fails --- src/common/vncauth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/vncauth.c b/src/common/vncauth.c index c3f318c3a..5ef3c5aab 100644 --- a/src/common/vncauth.c +++ b/src/common/vncauth.c @@ -102,7 +102,10 @@ rfbEncryptAndStorePasswd(char *passwd, char *fname) /* Do encryption in-place - this way we overwrite our copy of the plaintext password */ - encrypt_rfbdes(encryptedPasswd, &out_len, fixedkey, encryptedPasswd, sizeof(encryptedPasswd)); + if (encrypt_rfbdes(encryptedPasswd, &out_len, fixedkey, encryptedPasswd, sizeof(encryptedPasswd)) == 0) { + fclose(fp); + return 1; + } for (i = 0; i < 8; i++) { putc(encryptedPasswd[i], fp);