Skip to content

Commit

Permalink
ureport: Strange usage of tmp variable
Browse files Browse the repository at this point in the history
I do not know why this tmp variable was used this way.
Probably a leftover from some refactoring..
  • Loading branch information
mzidek-gh authored and michalfabik committed Apr 28, 2021
1 parent 4be518f commit 52e9887
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/lib/ureport.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,30 @@ ureport_server_config_load_basic_auth(struct ureport_server_config *config,

g_autoptr(GHashTable) settings = NULL;

g_autofree char *tmp_password = NULL;
g_autofree char *tmp_username = NULL;
const char *username = NULL;
const char *password = NULL;
g_autofree const char *username = NULL;
const char *password_from_http_auth_pref = NULL;

username = tmp_username = g_strdup(http_auth_pref);
password = strchr(tmp_username, ':');
username = g_strdup(http_auth_pref);
password_from_http_auth_pref = strchr(username, ':');

if (password != NULL)
if (password_from_http_auth_pref != NULL) {
/* It is "char *", see strchr() few lines above. */
*((char *)(password++)) = '\0';
*((char *)(password_from_http_auth_pref++)) = '\0';
}

if (password == NULL)
{
if (password_from_http_auth_pref == NULL) {
g_autofree char *message = g_strdup_printf("Please provide uReport server password for user '%s':", username);
password = tmp_password = libreport_ask_password(message);
g_autofree char *password_from_input = libreport_ask_password(message);

if (strcmp(password, "") == 0)
if (strcmp(password_from_input, "") == 0) {
error_msg_and_die("Cannot continue without uReport server password!");
}

libreport_ureport_server_config_set_basic_auth(config, username, password_from_input);
} else {
libreport_ureport_server_config_set_basic_auth(config, username, password_from_http_auth_pref);
}

libreport_ureport_server_config_set_basic_auth(config, username, password);
}

void
Expand Down

0 comments on commit 52e9887

Please sign in to comment.