mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
added -Wextra -Werror and fixed everything it had to mecker about
This commit is contained in:
@@ -32,7 +32,10 @@ Key::Key() {
|
||||
|
||||
Key::Key(bool generate) {
|
||||
stored = false;
|
||||
if(generate)
|
||||
K = pcpkey_new();
|
||||
else
|
||||
K = NULL;
|
||||
}
|
||||
|
||||
Key::Key(const string& passphrase) {
|
||||
|
||||
@@ -282,6 +282,7 @@ if test -n "$bigendian"; then
|
||||
CFLAGS="$CFLAGS -D__CPU_IS_BIG_ENDIAN=1"
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -Werror -Wextra"
|
||||
CXXFLAGS="$CFLAGS"
|
||||
|
||||
AC_SUBST(PACKAGE_VERSION)
|
||||
|
||||
@@ -8,6 +8,7 @@ extern "C" {
|
||||
#include "pcp/config.h"
|
||||
#include "pcp/base85.h"
|
||||
#include "pcp/buffer.h"
|
||||
#include "pcp/config.h"
|
||||
#include "pcp/crypto.h"
|
||||
#include "pcp/defines.h"
|
||||
#include "pcp/digital_crc32.h"
|
||||
|
||||
@@ -257,7 +257,7 @@ void ps_armor(Pcpstream *stream, size_t blocksize);
|
||||
/* read from primary source, decode z85 and out into cache.
|
||||
if buf != NULL, consider it as the start of encoded data
|
||||
and remove headers and comments, then continue as normal. */
|
||||
size_t ps_read_decode(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsize);
|
||||
size_t ps_read_decode(Pcpstream *stream, void *buf, size_t bufsize);
|
||||
|
||||
/* determine if primary source is z85 encoded, put the data
|
||||
read from it into the cache */
|
||||
|
||||
@@ -239,8 +239,8 @@ int pcpvault_copy(vault_t *tmp, vault_t *vault);
|
||||
/* delete a vault file */
|
||||
void pcpvault_unlink(vault_t *tmp);
|
||||
|
||||
/* calculate the vault checksum */
|
||||
byte *pcpvault_create_checksum(vault_t *vault);
|
||||
/* calculate the checksum of the current vault */
|
||||
byte *pcpvault_create_checksum();
|
||||
|
||||
/* write the new checksum to the header of the current vault */
|
||||
void pcpvault_update_checksum(vault_t *vault);
|
||||
|
||||
@@ -24,7 +24,7 @@ static char de85[256];
|
||||
|
||||
static void prep_base85(void)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
if (de85['Z'])
|
||||
return;
|
||||
for (i = 0; i < ARRAY_SIZE(en85); i++) {
|
||||
|
||||
@@ -165,10 +165,10 @@ size_t pcp_decrypt_stream(Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *sym
|
||||
pcp_pubkey_t *cur = NULL;
|
||||
pcp_pubkey_t *sender = NULL;
|
||||
byte *reccipher = NULL;
|
||||
int nrec, recmatch, self;
|
||||
int recmatch, self;
|
||||
uint32_t lenrec;
|
||||
byte head[1];
|
||||
size_t cur_bufsize, rec_size;
|
||||
size_t cur_bufsize, rec_size, nrec;
|
||||
|
||||
byte rec_buf[PCP_ASYM_RECIPIENT_SIZE];
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ pcp_pubkey_t *pcp_ed_verify_buffered(Pcpstream *in, pcp_pubkey_t *p) {
|
||||
|
||||
/* printf("offset: %ld, full: %ld, cur: %ld\n", offset, full_bufsize, cur_bufsize); */
|
||||
|
||||
if(offset >= 0 && offset <= PCP_BLOCK_SIZE/2) {
|
||||
if(offset > 0 && offset <= PCP_BLOCK_SIZE/2) {
|
||||
/* sig begins within the first half, adjust in_buf size */
|
||||
/* printf("1st half\n"); */
|
||||
next_bufsize = 0;
|
||||
|
||||
@@ -467,7 +467,6 @@ Buffer *pcp_export_c_pub(pcp_key_t *sk) {
|
||||
struct tm *c;
|
||||
time_t t = time(0);
|
||||
c = localtime(&t);
|
||||
size_t i;
|
||||
|
||||
buffer_add_str(b, "/*\n * C export of public key\n");
|
||||
buffer_add_str(b, " * Generated on: %04d-%02d-%02dT%02d:%02d:%02d\n",
|
||||
|
||||
@@ -28,7 +28,7 @@ void pcp_pad_prepend(byte **padded, byte *unpadded,
|
||||
byte *tmp = ucmalloc(unpadlen + padlen);
|
||||
|
||||
/* pcp_append orig */
|
||||
int i;
|
||||
size_t i;
|
||||
for(i=0; i<unpadlen; ++i) {
|
||||
tmp[i + padlen] = unpadded[i];
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void pcp_pad_remove(byte **unpadded, byte *padded,
|
||||
*unpadded = ucmalloc(unpadlen * sizeof(byte));
|
||||
byte *tmp = ucmalloc(unpadlen);
|
||||
|
||||
int i;
|
||||
size_t i;
|
||||
for(i=0; i<unpadlen; ++i) {
|
||||
tmp[i] = padded[padlen + i];
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) {
|
||||
size_t ps_read_next(Pcpstream *stream) {
|
||||
if(stream->armor == 1) {
|
||||
/* fetch next chunk and decode it */
|
||||
return ps_read_decode(stream, stream->next, NULL, 0);
|
||||
return ps_read_decode(stream, NULL, 0);
|
||||
}
|
||||
else {
|
||||
/* unencoded source, fetch as is */
|
||||
@@ -192,7 +192,7 @@ void ps_determine(Pcpstream *stream) {
|
||||
if(_buffer_is_binary(buf, got) == 0) {
|
||||
/* no, it's armored */
|
||||
stream->armor = 1;
|
||||
ps_read_decode(stream, stream->cache, buf, got);
|
||||
ps_read_decode(stream, buf, got);
|
||||
}
|
||||
else {
|
||||
/* just put the raw stuff into the cache */
|
||||
@@ -200,8 +200,7 @@ void ps_determine(Pcpstream *stream) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t ps_read_decode(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsize) {
|
||||
size_t zdiff = 1;
|
||||
size_t ps_read_decode(Pcpstream *stream, void *buf, size_t bufsize) {
|
||||
size_t i = 0;
|
||||
uint8_t is_comment = 0;
|
||||
uint8_t c;
|
||||
@@ -247,57 +246,6 @@ size_t ps_read_decode(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsiz
|
||||
return outlen;
|
||||
}
|
||||
|
||||
size_t ps_read_decodeOLD(Pcpstream *stream, Buffer *cache, void *buf, size_t bufsize) {
|
||||
size_t zdiff = 1;
|
||||
size_t i = 0;
|
||||
Buffer *z = buffer_new(32, "ztemp");
|
||||
|
||||
if(bufsize > 0) {
|
||||
/* remove newlines, comments and headers, if any */
|
||||
char *z85 = pcp_readz85string(buf, bufsize);
|
||||
buffer_add(z, z85, strlen(z85));
|
||||
|
||||
/* check if we need to read more in order to get a full block */
|
||||
zdiff = stream->blocksize - strlen(z85);
|
||||
i = strlen(z85);
|
||||
free(z85);
|
||||
}
|
||||
|
||||
if(zdiff > 0) {
|
||||
/* read in bytewise, ignore newlines and add until the block is full */
|
||||
uint8_t c;
|
||||
while (i < stream->blocksize) {
|
||||
if (ps_read_raw(stream, &c, 1) == 1) {
|
||||
if(c != '\r' && c != '\n') {
|
||||
buffer_add8(z, c);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* finally, decode it and put into cache */
|
||||
size_t binlen, outlen;
|
||||
byte *bin = pcp_z85_decode(buffer_get_str(z), &binlen);
|
||||
if(bin == NULL) {
|
||||
/* it's not z85 encoded, so threat it as binary */
|
||||
stream->armor = 1;
|
||||
buffer_add_buf(stream->cache, z);
|
||||
outlen = buffer_size(stream->cache);
|
||||
}
|
||||
else {
|
||||
/* yes, successfully decoded it, put into cache */
|
||||
buffer_add(stream->cache, bin, binlen);
|
||||
outlen = binlen;
|
||||
}
|
||||
|
||||
buffer_free(z);
|
||||
|
||||
return outlen;
|
||||
}
|
||||
|
||||
size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes) {
|
||||
Buffer *z = buffer_new(32, "Pcpwritetemp");
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ byte* pcp_scrypt(char *passwd, size_t passwdlen, byte *nonce, size_t noncelen) {
|
||||
uint32_t p = 1;
|
||||
size_t buflen = 64;
|
||||
|
||||
if (crypto_scrypt(passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) {
|
||||
if (crypto_scrypt((byte *)passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) {
|
||||
return dk;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -255,7 +255,7 @@ int pcpvault_writeall(vault_t *vault) {
|
||||
}
|
||||
|
||||
void pcpvault_update_checksum(vault_t *vault) {
|
||||
byte *checksum = pcpvault_create_checksum(vault);
|
||||
byte *checksum = pcpvault_create_checksum();
|
||||
|
||||
vault_header_t *header = ucmalloc(sizeof(vault_header_t));
|
||||
header->fileid = PCP_VAULT_ID;
|
||||
@@ -270,7 +270,7 @@ void pcpvault_update_checksum(vault_t *vault) {
|
||||
fseek(vault->fd, 0, SEEK_END);
|
||||
}
|
||||
|
||||
byte *pcpvault_create_checksum(vault_t *vault) {
|
||||
byte *pcpvault_create_checksum() {
|
||||
int numskeys = pcphash_count();
|
||||
int numpkeys = pcphash_countpub();
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ char *pcp_readz85file(FILE *infile) {
|
||||
}
|
||||
|
||||
char *pcp_readz85string(byte *input, size_t bufsize) {
|
||||
int i;
|
||||
size_t i;
|
||||
size_t MAXLINE = 1024;
|
||||
|
||||
if(bufsize == 0) {
|
||||
|
||||
@@ -428,7 +428,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int
|
||||
|
||||
|
||||
|
||||
int pcp_importsecret (vault_t *vault, FILE *in, char *passwd) {
|
||||
int pcp_importsecret (FILE *in, char *passwd) {
|
||||
byte *buf = ucmalloc(2048);
|
||||
size_t buflen = fread(buf, 1, 2048, in);
|
||||
pcp_key_t *sk = NULL;
|
||||
|
||||
@@ -58,7 +58,7 @@ char *pcp_normalize_id(char *keyid);
|
||||
pcp_key_t *pcp_find_primary_secret();
|
||||
|
||||
int pcp_importpublic (vault_t *vault, FILE *in);
|
||||
int pcp_importsecret (vault_t *vault, FILE *in, char *passwd);
|
||||
int pcp_importsecret (FILE *in, char *passwd);
|
||||
|
||||
void pcpdelete_key(char *keyid);
|
||||
char *pcp_find_id_byrec(char *recipient);
|
||||
|
||||
@@ -162,7 +162,7 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out) {
|
||||
byte *hash = pcppubkey_getchecksum(key);
|
||||
fprintf(out, " Checksum: ");
|
||||
|
||||
int i;
|
||||
size_t i;
|
||||
for ( i = 0;i <15 ;++i) fprintf(out, "%02X:",(unsigned int) hash[i]);
|
||||
fprintf(out, "%02X", hash[15]);
|
||||
fprintf(out, "\n ");
|
||||
@@ -174,7 +174,8 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out) {
|
||||
|
||||
char *r = pcppubkey_get_art(key);
|
||||
fprintf(out, " Random Art ID: ");
|
||||
for (i=0; i<strlen(r); ++i) {
|
||||
size_t rlen = strlen(r);
|
||||
for (i=0; i<rlen; ++i) {
|
||||
if(r[i] == '\n') {
|
||||
fprintf(out, "\n ");
|
||||
}
|
||||
@@ -208,12 +209,13 @@ void pcpkey_print(pcp_key_t *key, FILE* out) {
|
||||
}
|
||||
|
||||
void pcpkey_printshortinfo(pcp_key_t *key) {
|
||||
int i;
|
||||
size_t i;
|
||||
printf(" Key-ID: 0x%s\n", key->id);
|
||||
printf(" Owner: %s\n", key->owner);
|
||||
char *r = pcpkey_get_art(key);
|
||||
printf(" Random Art ID: ");
|
||||
for (i=0; i<strlen(r); ++i) {
|
||||
size_t rlen = strlen(r);
|
||||
for (i=0; i<rlen; ++i) {
|
||||
if(r[i] == '\n') {
|
||||
printf("\n ");
|
||||
}
|
||||
@@ -226,12 +228,13 @@ void pcpkey_printshortinfo(pcp_key_t *key) {
|
||||
}
|
||||
|
||||
void pcppubkey_printshortinfo(pcp_pubkey_t *key) {
|
||||
int i;
|
||||
size_t i;
|
||||
printf(" Key-ID: 0x%s\n", key->id);
|
||||
printf(" Owner: %s\n", key->owner);
|
||||
char *r = pcppubkey_get_art(key);
|
||||
printf(" Random Art ID: ");
|
||||
for (i=0; i<strlen(r); ++i) {
|
||||
size_t rlen = strlen(r);
|
||||
for (i=0; i<rlen; ++i) {
|
||||
if(r[i] == '\n') {
|
||||
printf("\n ");
|
||||
}
|
||||
@@ -312,7 +315,7 @@ void pcpexport_yaml(char *outfile) {
|
||||
}
|
||||
|
||||
void pcpprint_bin(FILE *out, byte *data, size_t len) {
|
||||
int i;
|
||||
size_t i;
|
||||
for ( i = 0;i < len;++i)
|
||||
fprintf(out, "%02x", (unsigned int) data[i]);
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ int main (int argc, char **argv) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcp_importsecret(vault, in, xpass);
|
||||
pcp_importsecret(in, xpass);
|
||||
break;
|
||||
|
||||
case PCP_MODE_DELETE_KEY:
|
||||
|
||||
@@ -37,7 +37,7 @@ int main() {
|
||||
}
|
||||
|
||||
void pr(char *t, unsigned char *b, size_t s) {
|
||||
int i;
|
||||
size_t i;
|
||||
printf("%s:\n", t);
|
||||
for(i=0; i<s; ++i)
|
||||
printf("%02x", (unsigned int) b[i]);
|
||||
|
||||
Reference in New Issue
Block a user