From 12bf43022aeb23269ab523695e4e4965b356da8d Mon Sep 17 00:00:00 2001 From: night0721 <night@night0721.xyz> Date: Sun, 9 Mar 2025 11:44:43 +0000 Subject: [PATCH] Fix segfault when generating password --- apm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apm.c b/apm.c index 477a3c8..f7f909a 100644 --- a/apm.c +++ b/apm.c @@ -166,7 +166,9 @@ void encrypt_password(const char *name, char *password) size_t pw_len = strlen(password); /* find last \n and replace with 0 */ - strrchr(password, '\n')[0] = '\0'; + if (strrchr(password, '\n') != NULL) { + strrchr(password, '\n')[0] = '\0'; + } char data[1024]; /* max 1024 bytes */ strcpy(data, password);