Skip to content

Commit

Permalink
Fix mosquitto_passwd -U backup file creation.
Browse files Browse the repository at this point in the history
Closes #2873.
  • Loading branch information
ralight committed Aug 22, 2023
1 parent bfb373d commit 47ae6dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.txt
Expand Up @@ -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
===================
Expand Down
5 changes: 3 additions & 2 deletions apps/mosquitto_passwd/mosquitto_passwd.c
Expand Up @@ -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;

Expand Down

0 comments on commit 47ae6dd

Please sign in to comment.