[Mixmaster-devel] CVS: Mix/Src buffers.c,1.2,1.3 crypto.c,1.4,1.5 keymgt.c,1.6,1.7 mail.c,1.4,1.5 ma
Brought to you by:
weaselp
From: Peter P. <we...@us...> - 2002-08-03 17:08:09
|
Update of /cvsroot/mixmaster/Mix/Src In directory usw-pr-cvs1:/tmp/cvs-serv18493/Src Modified Files: buffers.c crypto.c keymgt.c mail.c main.c mime.c mix.h pgp.c pgpcreat.c pgpdata.c pgpget.c pool.c random.c rem.c rndseed.c Log Message: Submitted By: Sami Farin (safari): Included correct header files. Src/main.c had incorrect param to buf_appendf. Added buf_write_sync() (used by Src/rem.c:mix_pool()). Should a mixmaster machine crash, pool file can contain any random data after reboot/journal recovery (at least when using reiserfs). Maybe not relevant, but strrchr should be used instead of strchr when looking for domain part. Src/pgpdata.c:pgp_elgdecrypt() passes uninitialized values to BN_free if BN_CTX_new fails. Src/pgpdata.c:pgp_elgencrypt() passes uninitialized value to BN_free if the third mpi_get(key, i) fails. Src/random.c does not check return value of read(). Src/rndseed.c does not check return value of read(). Index: buffers.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/buffers.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** buffers.c 29 Jul 2002 23:52:00 -0000 1.2 --- buffers.c 3 Aug 2002 17:08:01 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- #endif #include <assert.h> + #ifdef POSIX + #include <unistd.h> + #endif static void fail(void) *************** *** 342,345 **** --- 345,372 ---- return (fwrite(buffer->data, 1, buffer->length, out) == buffer->length ? 0 : -1); + } + + int buf_write_sync(BUFFER *buffer, FILE *out) + { + int ret = 0; + + if (buf_write(buffer, out) == -1) { + fclose(out); + return -1; + } + + if (fflush(out) != 0) + ret = -1; + + #ifdef POSIX + /* dir entry not synced */ + if (fsync(fileno(out)) != 0) + ret = -1; + #endif + + if (fclose(out) != 0) + ret = -1; + + return ret; } Index: crypto.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/crypto.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** crypto.c 24 Jul 2002 07:48:50 -0000 1.4 --- crypto.c 3 Aug 2002 17:08:01 -0000 1.5 *************** *** 13,16 **** --- 13,17 ---- #include "crypto.h" #include <assert.h> + #include <string.h> #ifdef USE_OPENSSL Index: keymgt.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/keymgt.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** keymgt.c 25 Jul 2002 14:11:37 -0000 1.6 --- keymgt.c 3 Aug 2002 17:08:01 -0000 1.7 *************** *** 247,251 **** #ifdef USE_RSA ! int v2keymgt(force) { /* scan secring, write the pubkey. function will be rewritten --- 247,251 ---- #ifdef USE_RSA ! int v2keymgt(int force) { /* scan secring, write the pubkey. function will be rewritten Index: mail.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/mail.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mail.c 29 Jul 2002 23:52:00 -0000 1.4 --- mail.c 3 Aug 2002 17:08:01 -0000 1.5 *************** *** 17,21 **** #if defined(UNIX) && defined(USE_SOCK) #include <unistd.h> - #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> --- 17,20 ---- Index: main.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/main.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** main.c 24 Jul 2002 07:00:16 -0000 1.8 --- main.c 3 Aug 2002 17:08:02 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- #include <string.h> #include <ctype.h> + #include <stdlib.h> #ifdef POSIX #include <unistd.h> *************** *** 223,227 **** case 'r': if (i < argc - 1) ! buf_appendf(msg, "Reply-Chain: %s\n, argv[++i]"); else { noarg(argv[0], *p); --- 224,228 ---- case 'r': if (i < argc - 1) ! buf_appendf(msg, "Reply-Chain: %s\n", argv[++i]); else { noarg(argv[0], *p); *************** *** 521,527 **** buf_nl(chains); } ! if (strchr(nym, '@')) { ! strncpy(nymserver, strchr(nym, '@'), sizeof(nymserver)); ! *strchr(nym, '@') = '\0'; } if (nym_config(NYM_CREATE, nym, nymserver, pseudonym, --- 522,528 ---- buf_nl(chains); } ! if (strrchr(nym, '@')) { ! strncpy(nymserver, strrchr(nym, '@'), sizeof(nymserver)); ! *strrchr(nym, '@') = '\0'; } if (nym_config(NYM_CREATE, nym, nymserver, pseudonym, Index: mime.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/mime.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mime.c 12 Dec 2001 19:29:52 -0000 1.2 --- mime.c 3 Aug 2002 17:08:02 -0000 1.3 *************** *** 12,15 **** --- 12,16 ---- #include "mix3.h" #include <ctype.h> + #include <string.h> #define hex(i) (isdigit(i) ? (i) - '0' : tolower(i) - 'a' + 10) Index: mix.h =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/mix.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mix.h 29 Jul 2002 23:52:00 -0000 1.2 --- mix.h 3 Aug 2002 17:08:02 -0000 1.3 *************** *** 99,102 **** --- 99,110 ---- -1 otherwise. + int buf_write_sync(BUFFER *message, FILE *outfile); + + This function does the same as buf_write but also does + checks for return values of fflush, fsync and ***fclose***. + + Return values: + 0 if the buffer could be written, synced and closed completely, + -1 otherwise. Remailer Messages *************** *** 822,825 **** --- 830,834 ---- int buf_read(BUFFER *message, FILE *infile); int buf_write(BUFFER *message, FILE *outfile); + int buf_write_sync(BUFFER *message, FILE *outfile); #define MSG_MAIL 1 Index: pgp.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/pgp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pgp.c 1 Aug 2002 14:24:24 -0000 1.2 --- pgp.c 3 Aug 2002 17:08:02 -0000 1.3 *************** *** 14,17 **** --- 14,18 ---- #include "pgp.h" #include <ctype.h> + #include <string.h> int pgp_decrypt(BUFFER *in, BUFFER *pass, BUFFER *sig, char *pubring, Index: pgpcreat.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/pgpcreat.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pgpcreat.c 7 Nov 2001 00:44:09 -0000 1.3 --- pgpcreat.c 3 Aug 2002 17:08:02 -0000 1.4 *************** *** 16,20 **** #include <assert.h> #include <time.h> ! #include <time.h> int pgp_packet(BUFFER *in, int type) --- 16,20 ---- #include <assert.h> #include <time.h> ! #include <string.h> int pgp_packet(BUFFER *in, int type) Index: pgpdata.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/pgpdata.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pgpdata.c 22 Jul 2002 17:54:48 -0000 1.7 --- pgpdata.c 3 Aug 2002 17:08:02 -0000 1.8 *************** *** 16,20 **** #include <assert.h> #include <time.h> ! #include <time.h> int pgp_keylen(int symalgo) --- 16,20 ---- #include <assert.h> #include <time.h> ! #include <string.h> int pgp_keylen(int symalgo) *************** *** 420,424 **** int tempbuf = 0; int keytype = -1, type, j; ! int thisalgo, version, skalgo; int needsym = 0, symfound = 0; BUFFER *p1, *iv, *sk, *i, *thiskeyid; --- 420,424 ---- int tempbuf = 0; int keytype = -1, type, j; ! int thisalgo = 0, version, skalgo; int needsym = 0, symfound = 0; BUFFER *p1, *iv, *sk, *i, *thiskeyid; *************** *** 1140,1144 **** int pgp_elgdecrypt(BUFFER *in, BUFFER *key) { ! BIGNUM *a, *b, *c, *p, *g, *x; BN_CTX *ctx; BUFFER *i; --- 1140,1145 ---- int pgp_elgdecrypt(BUFFER *in, BUFFER *key) { ! BIGNUM *a = NULL, *b = NULL, *c = NULL, ! *p = NULL, *g = NULL, *x = NULL; BN_CTX *ctx; BUFFER *i; *************** *** 1193,1197 **** int pgp_elgencrypt(BUFFER *in, BUFFER *key) { ! BIGNUM *m, *k, *a, *b, *c, *p, *g, *y; BN_CTX *ctx; BUFFER *i; --- 1194,1198 ---- int pgp_elgencrypt(BUFFER *in, BUFFER *key) { ! BIGNUM *m, *k, *a, *b, *c, *p, *g, *y = NULL; BN_CTX *ctx; BUFFER *i; Index: pgpget.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/pgpget.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgpget.c 26 Jul 2002 23:29:45 -0000 1.5 --- pgpget.c 3 Aug 2002 17:08:02 -0000 1.6 *************** *** 16,19 **** --- 16,20 ---- #include <time.h> #include <assert.h> + #include <string.h> int pgp_getmsg(BUFFER *in, BUFFER *key, BUFFER *sig, char *pubring, *************** *** 24,28 **** int type, algo = 0; int err = PGP_NOMSG; ! pgpsig signature = {0, NULL}; p = buf_new(); --- 25,29 ---- int type, algo = 0; int err = PGP_NOMSG; ! pgpsig signature = {0, NULL, 0, 0, {0,} }; p = buf_new(); Index: pool.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/pool.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pool.c 11 May 2002 00:58:26 -0000 1.8 --- pool.c 3 Aug 2002 17:08:02 -0000 1.9 *************** *** 237,241 **** int size, max, i, r; BUFFER *pool; ! int *ptr; infile_read(); --- 237,241 ---- int size, max, i, r; BUFFER *pool; ! long int *ptr; infile_read(); *************** *** 246,250 **** goto end; ! ptr = malloc(size * sizeof(int)); if (ptr == NULL) --- 246,250 ---- goto end; ! ptr = malloc(size * sizeof(long int)); if (ptr == NULL) Index: random.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/random.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** random.c 31 Oct 2001 08:19:53 -0000 1.1.1.1 --- random.c 3 Aug 2002 17:08:02 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- #endif #include <assert.h> + #include <string.h> int rnd_state = RND_NOTSEEDED; *************** *** 111,116 **** fd = open(DEV_URANDOM, O_RDONLY); if (fd != -1) { ! read(fd, b, sizeof(b)); ! rnd_add(b, sizeof(b)); close(fd); } --- 112,121 ---- fd = open(DEV_URANDOM, O_RDONLY); if (fd != -1) { ! ssize_t ret; ! ! ret = read(fd, b, sizeof(b)); ! if (ret > 0) { ! rnd_add(b, ret); ! } close(fd); } Index: rem.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/rem.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** rem.c 29 Jul 2002 23:52:00 -0000 1.19 --- rem.c 3 Aug 2002 17:08:02 -0000 1.20 *************** *** 256,261 **** else fprintf(f, "%d 0\n", type); ! err = buf_write(msg, f); ! fclose(f); } if (err == 0) { --- 256,260 ---- else fprintf(f, "%d 0\n", type); ! err = buf_write_sync(msg, f); } if (err == 0) { Index: rndseed.c =================================================================== RCS file: /cvsroot/mixmaster/Mix/Src/rndseed.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rndseed.c 31 Oct 2001 08:19:53 -0000 1.1.1.1 --- rndseed.c 3 Aug 2002 17:08:02 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- #include <fcntl.h> #include <time.h> + #include <stdlib.h> #ifdef POSIX #include <unistd.h> *************** *** 126,130 **** else { bytes = read(fd, b, sizeof(b)); ! rnd_add(b, sizeof(b)); close(fd); if (bytes < NEEDED) { --- 127,135 ---- else { bytes = read(fd, b, sizeof(b)); ! if (bytes > 0) { ! rnd_add(b, bytes); ! } else { ! bytes = 0; ! } close(fd); if (bytes < NEEDED) { |