Fix mosquitto_passwd -U backup file creation.

Closes #2873.
This commit is contained in:
Roger A. Light 2023-08-22 08:09:36 +01:00
parent bfb373d774
commit 47ae6dd0e2
2 changed files with 6 additions and 2 deletions

View File

@ -5,6 +5,9 @@ Broker:
- Fix `max_queued_message 0` stopping clients from receiving messages.
Closes #2879.
Apps:
- Fix `mosquitto_passwd -U` backup file creation. Closes #2873.
2.0.16 - 2023-08-16
===================

View File

@ -629,13 +629,14 @@ int main(int argc, char *argv[])
return 1;
}
backup_file = malloc((size_t)strlen(password_file)+strlen(".backup.XXXXXX"));
size_t len = strlen(password_file) + strlen(".backup.XXXXXX") + 1;
backup_file = malloc(len);
if(!backup_file){
fprintf(stderr, "Error: Out of memory.\n");
free(password_file);
return 1;
}
snprintf(backup_file, strlen(password_file)+5, "%s.backup.XXXXXX", password_file);
snprintf(backup_file, len, "%s.backup.XXXXXX", password_file);
free(password_file);
password_file = NULL;