Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password fixes #94

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,6 @@ do_shutdown(context *ctx, int nsockets, struct pollfd *pollfds)
free(pollfds);
}

/* GCC -fanalyzer has trouble with realloc
* https://bugzilla.redhat.com/show_bug.cgi?id=2047926 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
static int
handle_events(context *ctx)
{
Expand Down Expand Up @@ -999,7 +995,6 @@ handle_events(context *ctx)
}
return 0;
}
#pragma GCC diagnostic pop

static int
get_uid_and_gid(context *ctx, char **homedir)
Expand Down
26 changes: 22 additions & 4 deletions src/password.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ read_password(FILE *in, FILE *out, char *buf, size_t bufsz)
int infd = fileno(in);
struct termios tio;
char *ret;
int len;

ingress();
ret = fgets(buf, bufsz, in);
Expand All @@ -96,7 +97,14 @@ read_password(FILE *in, FILE *out, char *buf, size_t bufsz)
if (ret == NULL)
return -1;

buf[strlen(buf)-1] = '\0';
len = strlen(buf);
while (len > 0 && (buf[len-1] == '\r' || buf[len-1] == '\n')) {
buf[len-1] = '\0';
len--;
}
if (len == 0)
return -1;

egress();
return 0;
}
Expand Down Expand Up @@ -365,13 +373,23 @@ SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
}

char *
get_password_passthrough(PK11SlotInfo *slot UNUSED,
PRBool retry, void *arg)
get_password_passthrough(PK11SlotInfo *slot UNUSED, PRBool retry, void *arg)
{
cms_context *cms;
secuPWData *pwdata;

dbgprintf("ctx:%p", arg);

if (retry || !arg)
return NULL;

char *ret = strdup(arg);
cms = (cms_context *)arg;
pwdata = &cms->pwdata;

if (pwdata->source != PW_PLAINTEXT)
return NULL;

char *ret = strdup(pwdata->data);
if (!ret)
err(1, "Could not allocate memory");

Expand Down