Mercurial > projects > pwm
changeset 5:0b1bce8db371
Prevent misleading double error message
Display errors from the function where they occur. Only use warn(x) for system
errors.
author | Guido Berhoerster <guido+pwm@berhoerster.name> |
---|---|
date | Sun, 05 Feb 2017 13:54:39 +0100 |
parents | b5c4267a7182 |
children | 4269feba381e |
files | pwfile.c pwm.c |
diffstat | 2 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pwfile.c Sun Feb 05 13:30:31 2017 +0100 +++ b/pwfile.c Sun Feb 05 13:54:39 2017 +0100 @@ -172,7 +172,7 @@ struct record_id_entry *entry; if (pws3_file_read_stream(ctx->file, ctx->password, fp) != 0) { - warnx("failed to read password database: %s", + fprintf(stderr, "failed to read password database: %s\n", pws3_file_get_error_message(ctx->file)); return (-1); }
--- a/pwm.c Sun Feb 05 13:30:31 2017 +0100 +++ b/pwm.c Sun Feb 05 13:54:39 2017 +0100 @@ -197,10 +197,12 @@ password_len--; if (password_len == 0) { /* first line is empty */ + fprintf(stderr, "malformed password file\n"); goto out; } } else if (!feof(fp)) { /* the first line was truncated, password is too long */ + fprintf(stderr, "malformed password file\n"); goto out; } memcpy(password, buf, password_size); @@ -318,7 +320,6 @@ if (master_password_filename != NULL) { if (read_password_from_file(master_password_filename, ctx.password, sizeof (ctx.password)) != 0) { - fprintf(stderr, "malformed password database\n"); goto out; } } else {