added missing newlines to error messages

This commit is contained in:
git@daemon.de
2014-05-05 12:01:55 +02:00
parent 7ae0cedcb1
commit 64eb4651f8
6 changed files with 20 additions and 18 deletions

View File

@@ -34,7 +34,7 @@ byte* pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_
return dk; return dk;
} }
else { else {
fatal(ptx, "crypto_scrypt() failed"); fatal(ptx, "crypto_scrypt() failed\n");
return NULL; return NULL;
} }

View File

@@ -82,7 +82,7 @@ vault_t *pcpvault_new(PCPCTX *ptx, char *filename, int is_tmp) {
vault->isnew = 1; vault->isnew = 1;
mode_t old_mask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH); mode_t old_mask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH);
if((fd = fopen(vault->filename, "wb+")) == NULL) { if((fd = fopen(vault->filename, "wb+")) == NULL) {
fatal(ptx, "Could not create vault file %s", vault->filename); fatal(ptx, "Could not create vault file %s\n", vault->filename);
umask (old_mask); umask (old_mask);
goto errn; goto errn;
} }
@@ -90,7 +90,7 @@ vault_t *pcpvault_new(PCPCTX *ptx, char *filename, int is_tmp) {
} }
else { else {
if((fd = fopen(vault->filename, "rb+")) == NULL) { if((fd = fopen(vault->filename, "rb+")) == NULL) {
fatal(ptx, "Could not open vault file %s", vault->filename); fatal(ptx, "Could not open vault file %s\n", vault->filename);
goto errn; goto errn;
} }
} }

View File

@@ -199,7 +199,7 @@ byte *pcp_z85_decode(PCPCTX *ptx, char *z85block, size_t *dstlen) {
bin = ucmalloc(binlen); bin = ucmalloc(binlen);
if(zmq_z85_decode(bin, z85block) == NULL) { if(zmq_z85_decode(bin, z85block) == NULL) {
fatal(ptx, "zmq_z85_decode() failed, input size ! mod 5 (got %ld)", strlen(z85block)); fatal(ptx, "zmq_z85_decode() failed, input size ! mod 5 (got %ld)\n", strlen(z85block));
return NULL; return NULL;
} }
@@ -287,7 +287,7 @@ char *pcp_readz85string(PCPCTX *ptx, unsigned char *input, size_t bufsize) {
} }
if(_buffer_is_binary(input, bufsize) > 0) { if(_buffer_is_binary(input, bufsize) > 0) {
fatal(ptx, "input is not z85 encoded and contains pure binary data"); fatal(ptx, "input is not z85 encoded and contains pure binary data\n");
return NULL; return NULL;
} }
@@ -339,7 +339,7 @@ char *pcp_readz85string(PCPCTX *ptx, unsigned char *input, size_t bufsize) {
} }
if(buffer_size(z) == 0) { if(buffer_size(z) == 0) {
fatal(ptx, "empty z85 encoded string"); fatal(ptx, "empty z85 encoded string\n");
goto rferr; goto rferr;
} }

View File

@@ -30,14 +30,14 @@ char *pcp_getstdin(const char *prompt) {
fprintf(stderr, "%s: ", prompt); fprintf(stderr, "%s: ", prompt);
if (fgets(line, 255, stdin) == NULL) { if (fgets(line, 255, stdin) == NULL) {
fatal(ptx, "Cannot read from stdin"); fatal(ptx, "Cannot read from stdin\n");
goto errgst; goto errgst;
} }
line[strcspn(line, "\r\n")] = '\0'; line[strcspn(line, "\r\n")] = '\0';
if ((out = strdup(line)) == NULL) { if ((out = strdup(line)) == NULL) {
fatal(ptx, "Cannot allocate memory"); fatal(ptx, "Cannot allocate memory\n");
goto errgst; goto errgst;
} }
@@ -222,7 +222,7 @@ void pcp_exportsecret(char *keyid, int useid, char *outfile, int armor, char *pa
} }
else { else {
if((out = fopen(outfile, "wb+")) == NULL) { if((out = fopen(outfile, "wb+")) == NULL) {
fatal(ptx, "Could not create output file %s", outfile); fatal(ptx, "Could not create output file %s\n", outfile);
goto errexpse1; goto errexpse1;
} }
} }
@@ -307,7 +307,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int
} }
else { else {
if((out = fopen(outfile, "wb+")) == NULL) { if((out = fopen(outfile, "wb+")) == NULL) {
fatal(ptx, "Could not create output file %s", outfile); fatal(ptx, "Could not create output file %s\n", outfile);
goto errpcpexpu1; goto errpcpexpu1;
} }
} }
@@ -381,7 +381,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int
} }
else { else {
/* FIXME: export foreign keys unsupported yet */ /* FIXME: export foreign keys unsupported yet */
fatal(ptx, "Exporting foreign public keys in native format unsupported yet"); fatal(ptx, "Exporting foreign public keys in native format unsupported yet\n");
goto errpcpexpu1; goto errpcpexpu1;
} }
} }
@@ -399,7 +399,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int
} }
} }
else { else {
fatal(ptx, "Exporting foreign public keys in PBP format not possible"); fatal(ptx, "Exporting foreign public keys in PBP format not possible\n");
goto errpcpexpu1; goto errpcpexpu1;
} }
} }
@@ -615,6 +615,8 @@ int pcp_import (vault_t *vault, FILE *in, char *passwd) {
} }
else { else {
/* it's not public key, so let's try to interpret it as secret key */ /* it's not public key, so let's try to interpret it as secret key */
if(ptx->verbose)
fatals_ifany(ptx);
if(passwd != NULL) { if(passwd != NULL) {
sk = pcp_import_secret(ptx, buf, bufsize, passwd); sk = pcp_import_secret(ptx, buf, bufsize, passwd);
} }

View File

@@ -305,7 +305,7 @@ void pcpexport_yaml(char *outfile) {
} }
else { else {
if((out = fopen(outfile, "wb+")) == NULL) { if((out = fopen(outfile, "wb+")) == NULL) {
fatal(ptx, "Could not create output file %s", outfile); fatal(ptx, "Could not create output file %s\n", outfile);
out = NULL; out = NULL;
} }
} }

View File

@@ -58,13 +58,13 @@ pcp_readpass(char ** passwd, const char * prompt,
/* If we're reading from a terminal, try to disable echo. */ /* If we're reading from a terminal, try to disable echo. */
if ((usingtty = isatty(fileno(readfrom))) != 0) { if ((usingtty = isatty(fileno(readfrom))) != 0) {
if (tcgetattr(fileno(readfrom), &term_old)) { if (tcgetattr(fileno(readfrom), &term_old)) {
fatal(ptx, "Cannot read terminal settings"); fatal(ptx, "Cannot read terminal settings\n");
goto err1; goto err1;
} }
memcpy(&term, &term_old, sizeof(struct termios)); memcpy(&term, &term_old, sizeof(struct termios));
term.c_lflag = (term.c_lflag & ~ECHO) | ECHONL; term.c_lflag = (term.c_lflag & ~ECHO) | ECHONL;
if (tcsetattr(fileno(readfrom), TCSANOW, &term)) { if (tcsetattr(fileno(readfrom), TCSANOW, &term)) {
fatal(ptx, "Cannot set terminal settings"); fatal(ptx, "Cannot set terminal settings\n");
goto err1; goto err1;
} }
} }
@@ -76,7 +76,7 @@ retry:
/* Read the password. */ /* Read the password. */
if (fgets(passbuf, MAXPASSLEN, readfrom) == NULL) { if (fgets(passbuf, MAXPASSLEN, readfrom) == NULL) {
fatal(ptx, "Cannot read password"); fatal(ptx, "Cannot read password\n");
goto err2; goto err2;
} }
@@ -85,7 +85,7 @@ retry:
if (usingtty) if (usingtty)
fprintf(stderr, "%s: ", confirmprompt); fprintf(stderr, "%s: ", confirmprompt);
if (fgets(confpassbuf, MAXPASSLEN, readfrom) == NULL) { if (fgets(confpassbuf, MAXPASSLEN, readfrom) == NULL) {
fatal(ptx, "Cannot read password"); fatal(ptx, "Cannot read password\n");
goto err2; goto err2;
} }
if (strcmp(passbuf, confpassbuf)) { if (strcmp(passbuf, confpassbuf)) {
@@ -108,7 +108,7 @@ retry:
/* Copy the password out. */ /* Copy the password out. */
if ((*passwd = strdup(passbuf)) == NULL) { if ((*passwd = strdup(passbuf)) == NULL) {
fatal(ptx, "Cannot allocate memory"); fatal(ptx, "Cannot allocate memory\n");
goto err1; goto err1;
} }