diff --git a/INSTALL b/INSTALL index 6e90e07..007e939 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation, +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, diff --git a/TODO b/TODO old mode 100644 new mode 100755 index 04955dc..30e5aea --- a/TODO +++ b/TODO @@ -27,17 +27,11 @@ pcp_find_primary_secret() makes a copy ??? c++ destructor double free mess -size_t 32bit/64bit: -buffer.c: In function 'buffer_info': -buffer.c:268:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:268:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:269:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:269:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:270:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:270:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:271:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -buffer.c:271:3: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' [-Werror=format] -http://stackoverflow.com/questions/2426113/i-have-having-following-warning-in-gcc-compilation-in-32-bit-architecture-but-no +win32 32bit ported so far, missing: +[15.Mrz 17:23:58] --- [~/pcp/tests] --- +scip@io: $ ../src/pcp1 -V v1 -K -I testkey-wrong-serial -x xxx +zmq_z85_decode() failed, input size ! mod 5 (got 98)failed to decrypt the secret key file + Python binding, e.g.: py % cdll.LoadLibrary("libsodium.so.8") diff --git a/bindings/cpp/sign.cpp b/bindings/cpp/sign.cpp old mode 100644 new mode 100755 index 2338c24..a428173 --- a/bindings/cpp/sign.cpp +++ b/bindings/cpp/sign.cpp @@ -60,7 +60,7 @@ bool Signature::sign(std::vector message) { Buffer *m = buffer_new(32, n); for(size_t i=0; i message) { Buf _sig = Buf(); for(size_t i=0; i #include #include - +#include "platform.h" #include "defines.h" diff --git a/libpcp/buffer.c b/libpcp/buffer.c old mode 100644 new mode 100755 index 1603380..641ed75 --- a/libpcp/buffer.c +++ b/libpcp/buffer.c @@ -265,10 +265,10 @@ void buffer_dump(const Buffer *b) { void buffer_info(const Buffer *b) { fprintf(stderr, " buffer: %s\n", b->name); - fprintf(stderr, "blocksize: %ld\n", b->blocksize); - fprintf(stderr, " size: %ld\n", b->size); - fprintf(stderr, " offset: %ld\n", b->offset); - fprintf(stderr, " end: %ld\n", b->end); + fprintf(stderr, "blocksize: %"FMT_SIZE_T"\n", (SIZE_T_CAST)b->blocksize); + fprintf(stderr, " size: %"FMT_SIZE_T"\n", (SIZE_T_CAST)b->size); + fprintf(stderr, " offset: %"FMT_SIZE_T"\n", (SIZE_T_CAST)b->offset); + fprintf(stderr, " end: %"FMT_SIZE_T"\n", (SIZE_T_CAST)b->end); fprintf(stderr, "allocated: %d\n\n", b->allocated); } @@ -329,7 +329,7 @@ size_t buffer_fd_read(Buffer *b, FILE *in, size_t len) { size_t s = fread(data, 1, len, in); if(s < len) { - fatal("[buffer %s] attempt to read %ld bytes from FILE, but got %ld bytes only\n", b->name, len, s); + fatal("[buffer %s] attempt to read %"FMT_SIZE_T" bytes from FILE, but got %"FMT_SIZE_T" bytes only\n", b->name, (SIZE_T_CAST)len, (SIZE_T_CAST)s); return 0; } diff --git a/libpcp/key.c b/libpcp/key.c old mode 100644 new mode 100755 index 1b67581..da77a89 --- a/libpcp/key.c +++ b/libpcp/key.c @@ -301,11 +301,55 @@ pcp_pubkey_t *pubkey2native(pcp_pubkey_t *k) { } void pcp_seckeyblob(void *blob, pcp_key_t *k) { - memcpy(blob, k, PCP_RAW_KEYSIZE); + //memcpy(blob, k, PCP_RAW_KEYSIZE); + Buffer *b = buffer_new(PCP_RAW_KEYSIZE, "bs"); + + buffer_add(b, k->masterpub, 32); + buffer_add(b, k->mastersecret, 64); + + buffer_add(b, k->pub, 32); + buffer_add(b, k->secret, 32); + + buffer_add(b, k->edpub, 32); + buffer_add(b, k->edsecret, 64); + + buffer_add(b, k->nonce, 24); + + buffer_add(b, k->encrypted, 176); + + buffer_add(b, k->owner, 255); + buffer_add(b, k->mail, 255); + buffer_add(b, k->id, 17); + + buffer_add8(b, k->type); + buffer_add64(b, k->ctime); + buffer_add32(b, k->version); + buffer_add32(b, k->serial); + // buffer_dump(b); + buffer_get_chunk(b, blob, b->end - b->offset); + buffer_free(b); } void pcp_pubkeyblob(void *blob, pcp_pubkey_t *k) { - memcpy(blob, k, PCP_RAW_PUBKEYSIZE); + Buffer *b = buffer_new(PCP_RAW_PUBKEYSIZE, "bp"); + + buffer_add(b, k->masterpub, 32); + buffer_add(b, k->sigpub, 32); + buffer_add(b, k->pub, 32); + buffer_add(b, k->edpub, 32); + + buffer_add(b, k->owner, 255); + buffer_add(b, k->mail, 255); + buffer_add(b, k->id, 17); + + buffer_add8(b, k->type); + buffer_add64(b, k->ctime); + buffer_add32(b, k->version); + buffer_add32(b, k->serial); + buffer_add8(b, k->valid); + + buffer_get_chunk(b, blob, b->end - b->offset); + buffer_free(b); } void *pcp_keyblob(void *k, int type) { diff --git a/libpcp/mgmt.c b/libpcp/mgmt.c old mode 100644 new mode 100755 diff --git a/libpcp/util.c b/libpcp/util.c old mode 100644 new mode 100755 index 7ba2908..fe9496f --- a/libpcp/util.c +++ b/libpcp/util.c @@ -61,7 +61,7 @@ void _xorbuf(byte *iv, byte *buf, size_t xlen) { /* print some binary data to stderr */ void _dump(char *n, byte *d, size_t s) { int l = strlen(n) + 9; - fprintf(stderr, "%s (%04ld): ", n, s); + fprintf(stderr, "%s (%04"FMT_SIZE_T"): ", n, (SIZE_T_CAST)s); size_t i; int c; for (i=0; ichecksum, 32); printf("\n"); + _dump(" calc checksum", checksum, 32); + _dump("vault checksum", vault->checksum, 32); */ if(pcphash_count() + pcphash_countpub() > 0) { diff --git a/src/encryption.c b/src/encryption.c old mode 100644 new mode 100755 index 6d8c924..708f316 --- a/src/encryption.c +++ b/src/encryption.c @@ -126,9 +126,9 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i if(dlen > 0) { if(verify) - fprintf(stderr, "Decrypted and Verified %ld bytes successfully\n", dlen); + fprintf(stderr, "Decrypted and Verified %"FMT_SIZE_T" bytes successfully\n", (SIZE_T_CAST)dlen); else - fprintf(stderr, "Decrypted %ld bytes successfully\n", dlen); + fprintf(stderr, "Decrypted %"FMT_SIZE_T" bytes successfully\n", (SIZE_T_CAST)dlen); return 0; } @@ -291,11 +291,11 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec if(clen > 0) { if(id == NULL && recipient == NULL) - fprintf(stderr, "Encrypted %ld bytes symetrically\n", clen); + fprintf(stderr, "Encrypted %"FMT_SIZE_T" bytes symetrically\n", (SIZE_T_CAST)clen); else if(id != NULL) - fprintf(stderr, "Encrypted %ld bytes for 0x%s successfully\n", clen, id); + fprintf(stderr, "Encrypted %"FMT_SIZE_T" bytes for 0x%s successfully\n", (SIZE_T_CAST)clen, id); else { - fprintf(stderr, "Encrypted %ld bytes for:\n", clen); + fprintf(stderr, "Encrypted %"FMT_SIZE_T" bytes for:\n", (SIZE_T_CAST)clen); pcp_pubkey_t *cur, *t; HASH_ITER(hh, pubhash, cur, t) { fprintf(stderr, "%s <%s>\n", cur->owner, cur->mail); diff --git a/src/signature.c b/src/signature.c old mode 100644 new mode 100755 index 5018240..194b2b4 --- a/src/signature.c +++ b/src/signature.c @@ -86,7 +86,7 @@ int pcpsign(char *infile, char *outfile, char *passwd, int z85, int detach) { if(sigsize == 0) goto errs1; - fprintf(stderr, "Signed %ld bytes successfully\n", sigsize); + fprintf(stderr, "Signed %"FMT_SIZE_T" bytes successfully\n", (SIZE_T_CAST)sigsize); return 0; diff --git a/tests/collisions.c b/tests/collisions.c old mode 100644 new mode 100755 index 450dd35..faa7ed0 --- a/tests/collisions.c +++ b/tests/collisions.c @@ -26,7 +26,7 @@ unsigned djb_hash ( void *key, int len ) { unsigned char *p = key; - unsigned h = 0; + unsigned h = 0U; int i; for ( i = 0; i < len; i++ ) @@ -37,7 +37,7 @@ unsigned djb_hash ( void *key, int len ) { unsigned fnv_hash ( void *key, int len ) { unsigned char *p = key; - unsigned h = 2166136261; + unsigned h = 2166136261U; int i; for ( i = 0; i < len; i++ ) diff --git a/tests/cpptest.cpp b/tests/cpptest.cpp old mode 100644 new mode 100755 index 16d5ae4..d11bf08 --- a/tests/cpptest.cpp +++ b/tests/cpptest.cpp @@ -60,8 +60,9 @@ void test0() { DECRYPTED = _openrd("testcppdecrypted"); char *got = (char *)ucmalloc(10); - size_t h; - h = fread(got, 1, 6, DECRYPTED); + if(fread(got, 1, 6, DECRYPTED) < 6) { + throw pcp::exception("read error, could not read decrypted content"); + } if(strncmp(got, "HALLO", 5) != 0) { throw pcp::exception(); } diff --git a/tests/gencheader.c b/tests/gencheader.c old mode 100644 new mode 100755 index 874cd5a..d931cc6 --- a/tests/gencheader.c +++ b/tests/gencheader.c @@ -1,8 +1,8 @@ #include void pr(char *var, unsigned char *d, size_t len) { - printf("size_t %s_len = %ld;\n", var, len); - printf("unsigned char %s[%ld] = {\n", var, len); + printf("size_t %s_len = %"FMT_SIZE_T";\n", var, (SIZE_T_CAST)len); + printf("unsigned char %s[%"FMT_SIZE_T"] = {\n", var, (SIZE_T_CAST)len); size_t i; for(i=0; i cmd = $pcp -V vb -c -d -I testsig -x b - expect = /Verified.*Unittests/s + expect = /Unittests.*Verified/s # diff --git a/tests/unittests.pl b/tests/unittests.pl index 7eaf909..b86ba38 100755 --- a/tests/unittests.pl +++ b/tests/unittests.pl @@ -21,6 +21,12 @@ # use lib qw(lib); +BEGIN { + eval { + use IPC::Run qw( run timeout); + }; +}; + use Test::More; use IPC::Open3; use IO::Select; @@ -29,7 +35,7 @@ use Config::General qw(ParseConfig); use Tie::IxHash; use Data::Dumper; -sub run; +sub run3; sub execute; sub final; @@ -119,7 +125,7 @@ sub runtest { print STDERR "\n$cfg->{cmd}\n "; - my $ret = run($cfg->{cmd}, + my $ret = run3($cfg->{cmd}, $cfg->{input}, \$out, \$error, 10, 0, undef); @@ -203,11 +209,26 @@ sub final { return $ret; } -sub run { +sub run3 { # open3 wrapper. catch stderr, stdout, errno; add timeout and kill my($cmd, $input, $output, $error, $timeout, $debug, $monitorfile) = @_; + if ($^O =~ /win/i) { + my ($o, $e, @c); + if ($cmd =~ /\|/) { + @c = ("sh", "-c", $cmd); + } + else { + @c = split /\s\s*/, $cmd; + } + my $ret = run \@c, \$input, \$o, \$e, timeout( $timeout ); + $$output = $o; + $$error = $e; + return ret; + } + my ($stdin, $stderr, $stdout) = ('', '', ''); + my $child = 0; my $cmdline = join " ", @{$cmd}; $timeout = $timeout ? $timeout : 10; @@ -320,6 +341,20 @@ sub run { } } +sub runipc { + my($cmd, $input, $output, $error, $timeout, $debug, $monitorfile) = @_; + + print STDERR Dumper(\@_); + + if (run $cmd, $input, $output, $error, timeout( $timeout )) { + return 0; + } + else { + return 1; + } + +} + sub reaper { my $pid; while (1) {