Fix segfault when generating password

This commit is contained in:
Night Kaly 2025-03-09 11:44:43 +00:00
parent 7b7e48f985
commit 12bf43022a
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM

4
apm.c
View file

@ -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);