Skip to content

Commit

Permalink
Make sure there cannot be a double free()
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Dec 28, 2023
1 parent 1eda75a commit 941e752
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/userinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint,
if (ret)
log_error("Error: %s\n", retstr);
free(retstr);
retstr = NULL;
if (ret)
goto out;

Expand All @@ -250,6 +251,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint,
if (ret)
log_error("Failed to set title: %s\n", retstr);
free(retstr);
retstr = NULL;
if (ret)
goto out;

Expand All @@ -258,6 +260,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint,
if (ret)
log_error("Failed to set description: %s\n", retstr);
free(retstr);
retstr = NULL;
if (ret)
goto out;

Expand All @@ -267,16 +270,19 @@ static void pinentry_read_password(const char *pinentry, const char *hint,
if (ret)
log_error("Failed to set keyinfo\n");
free(escaped);
escaped = NULL;
if (ret)
goto out;

escaped = uri_escape(prompt);
ret = pinentry_exchange(to_pinentry[1], from_pinentry[0], &retstr,
"SETPROMPT %s\n", escaped);
free(escaped);
escaped = NULL;
if (ret)
log_error("Failed to set prompt: %s\n", retstr);
free(retstr);
retstr = NULL;
if (ret)
goto out;

Expand All @@ -285,12 +291,14 @@ static void pinentry_read_password(const char *pinentry, const char *hint,
if (ret) {
log_error("Failed to get PIN: %s\n", retstr);
free(retstr);
retstr = NULL;
goto out;
}

if (retstr) {
strncpy(pass, retstr, len);
free(retstr);
retstr = NULL;
} else {
log_error("No password given\n");
}
Expand Down

0 comments on commit 941e752

Please sign in to comment.