comparison pwm.c @ 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 a7e41e1a79c8
children cf81eb0c2d5a
comparison
equal deleted inserted replaced
4:b5c4267a7182 5:0b1bce8db371
195 if (buf[password_len - 1] == '\n') { 195 if (buf[password_len - 1] == '\n') {
196 /* strip trailing newline */ 196 /* strip trailing newline */
197 password_len--; 197 password_len--;
198 if (password_len == 0) { 198 if (password_len == 0) {
199 /* first line is empty */ 199 /* first line is empty */
200 fprintf(stderr, "malformed password file\n");
200 goto out; 201 goto out;
201 } 202 }
202 } else if (!feof(fp)) { 203 } else if (!feof(fp)) {
203 /* the first line was truncated, password is too long */ 204 /* the first line was truncated, password is too long */
205 fprintf(stderr, "malformed password file\n");
204 goto out; 206 goto out;
205 } 207 }
206 memcpy(password, buf, password_size); 208 memcpy(password, buf, password_size);
207 retval = 0; 209 retval = 0;
208 210
316 } 318 }
317 /* obtain master password */ 319 /* obtain master password */
318 if (master_password_filename != NULL) { 320 if (master_password_filename != NULL) {
319 if (read_password_from_file(master_password_filename, 321 if (read_password_from_file(master_password_filename,
320 ctx.password, sizeof (ctx.password)) != 0) { 322 ctx.password, sizeof (ctx.password)) != 0) {
321 fprintf(stderr, "malformed password database\n");
322 goto out; 323 goto out;
323 } 324 }
324 } else { 325 } else {
325 if (readpassphrase("Enter password: ", ctx.password, 326 if (readpassphrase("Enter password: ", ctx.password,
326 sizeof (ctx.password), RPP_ECHO_OFF | RPP_REQUIRE_TTY) == 327 sizeof (ctx.password), RPP_ECHO_OFF | RPP_REQUIRE_TTY) ==