Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib Fix compilation:



details:   https://anonhg.NetBSD.org/src/rev/d2a7bbe6399d
branches:  trunk
changeset: 777796:d2a7bbe6399d
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 05 02:20:18 2012 +0000

description:
Fix compilation:
kill PGP_ERROR() and make everything use a format.
XXX: Fixme to use __VA_ARGS__ instead of the silly PGP_ERROR_N() macros.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/compress.c     |   10 +-
 crypto/external/bsd/netpgp/dist/src/lib/errors.h       |    3 -
 crypto/external/bsd/netpgp/dist/src/lib/misc.c         |    5 +-
 crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c |   22 +-
 crypto/external/bsd/netpgp/dist/src/lib/reader.c       |  106 +++++++++-------
 crypto/external/bsd/netpgp/dist/src/lib/signature.c    |    9 +-
 crypto/external/bsd/netpgp/dist/src/lib/validate.c     |   29 ++--
 crypto/external/bsd/netpgp/dist/src/lib/writer.c       |   10 +-
 8 files changed, 104 insertions(+), 90 deletions(-)

diffs (truncated from 604 to 300 lines):

diff -r 122cc2426805 -r d2a7bbe6399d crypto/external/bsd/netpgp/dist/src/lib/compress.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/compress.c        Sun Mar 04 21:14:55 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/compress.c        Mon Mar 05 02:20:18 2012 +0000
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: compress.c,v 1.22 2012/03/04 19:52:02 agc Exp $");
+__RCSID("$NetBSD: compress.c,v 1.23 2012/03/05 02:20:18 christos Exp $");
 #endif
 
 #ifdef HAVE_ZLIB_H
@@ -170,13 +170,14 @@
                        if (ret == Z_STREAM_END) {
                                if (!z->region->indeterminate &&
                                    z->region->readc != z->region->length) {
-                                       PGP_ERROR(cbinfo->errors,
+                                       PGP_ERROR_1(cbinfo->errors,
                                                PGP_E_P_DECOMPRESSION_ERROR,
+                                               "%s",
                                                "Compressed stream ended before packet end.");
                                }
                        } else if (ret != Z_OK) {
                                (void) fprintf(stderr, "ret=%d\n", ret);
-                               PGP_ERROR(cbinfo->errors,
+                               PGP_ERROR_1(cbinfo->errors,
                                        PGP_E_P_DECOMPRESSION_ERROR, "%s",
                                        z->zstream.msg);
                        }
@@ -250,8 +251,9 @@
                        if (ret == BZ_STREAM_END) {
                                if (!bz->region->indeterminate &&
                                    bz->region->readc != bz->region->length)
-                                       PGP_ERROR(cbinfo->errors,
+                                       PGP_ERROR_1(cbinfo->errors,
                                                PGP_E_P_DECOMPRESSION_ERROR,
+                                               "%s",
                                                "Compressed stream ended before packet end.");
                        } else if (ret != BZ_OK) {
                                PGP_ERROR_1(cbinfo->errors,
diff -r 122cc2426805 -r d2a7bbe6399d crypto/external/bsd/netpgp/dist/src/lib/errors.h
--- a/crypto/external/bsd/netpgp/dist/src/lib/errors.h  Sun Mar 04 21:14:55 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/errors.h  Mon Mar 05 02:20:18 2012 +0000
@@ -150,9 +150,6 @@
        fprintf(stderr, "Memory error\n");                              \
 }                              /* \todo placeholder for better error
                                 * handling */
-#define PGP_ERROR(err,code,fmt)        do {                                    \
-       pgp_push_error(err,code,0,__FILE__,__LINE__,fmt);               \
-} while(/*CONSTCOND*/0)
 #define PGP_ERROR_1(err,code,fmt,arg)  do {                            \
        pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg);           \
 } while(/*CONSTCOND*/0)
diff -r 122cc2426805 -r d2a7bbe6399d crypto/external/bsd/netpgp/dist/src/lib/misc.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/misc.c    Sun Mar 04 21:14:55 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/misc.c    Mon Mar 05 02:20:18 2012 +0000
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: misc.c,v 1.40 2010/11/29 06:21:40 agc Exp $");
+__RCSID("$NetBSD: misc.c,v 1.41 2012/03/05 02:20:18 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -132,7 +132,8 @@
                                        keyring->keyc - 1);
                }
                if (keyring->keyc == 0) {
-                       PGP_ERROR(cbinfo->errors, PGP_E_P_NO_USERID, "No userid found");
+                       PGP_ERROR_1(cbinfo->errors, PGP_E_P_NO_USERID, "%s",
+                           "No userid found");
                } else {
                        pgp_add_userid(&keyring->keys[keyring->keyc - 1], content->userid);
                }
diff -r 122cc2426805 -r d2a7bbe6399d crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c    Sun Mar 04 21:14:55 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c    Mon Mar 05 02:20:18 2012 +0000
@@ -58,7 +58,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: packet-parse.c,v 1.50 2010/11/15 08:56:30 agc Exp $");
+__RCSID("$NetBSD: packet-parse.c,v 1.51 2012/03/05 02:20:18 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -406,16 +406,17 @@
 
        if (!region->indeterminate &&
            region->readc + length > region->length) {
-               PGP_ERROR(errors, PGP_E_P_NOT_ENOUGH_DATA, "Not enough data");
+               PGP_ERROR_1(errors, PGP_E_P_NOT_ENOUGH_DATA, "%s",
+                   "Not enough data");
                return 0;
        }
        r = full_read(stream, dest, length, &lr, errors, readinfo, cbinfo);
        if (lr < 0) {
-               PGP_ERROR(errors, PGP_E_R_READ_FAILED, "Read failed");
+               PGP_ERROR_1(errors, PGP_E_R_READ_FAILED, "%s", "Read failed");
                return 0;
        }
        if (!region->indeterminate && r != length) {
-               PGP_ERROR(errors, PGP_E_R_READ_FAILED, "Read failed");
+               PGP_ERROR_1(errors, PGP_E_R_READ_FAILED, "%s", "Read failed");
                return 0;
        }
        region->last_read = (unsigned)r;
@@ -683,7 +684,8 @@
        }
        if (((unsigned)buf[0] >> nonzero) != 0 ||
            !((unsigned)buf[0] & (1U << (nonzero - 1U)))) {
-               PGP_ERROR(&stream->errors, PGP_E_P_MPI_FORMAT_ERROR, "MPI Format error");
+               PGP_ERROR_1(&stream->errors, PGP_E_P_MPI_FORMAT_ERROR,
+                   "%s", "MPI Format error");
                /* XXX: Ben, one part of
                 * this constraint does
                 * not apply to
@@ -2321,14 +2323,14 @@
                /* now throw it away */
                pgp_data_free(&remainder);
                if (warn) {
-                       PGP_ERROR(&stream->errors, PGP_E_P_PACKET_CONSUMED,
-                               "Warning: packet consumer");
+                       PGP_ERROR_1(&stream->errors, PGP_E_P_PACKET_CONSUMED,
+                           "%s", "Warning: packet consumer");
                }
                return 1;
        }
-       PGP_ERROR(&stream->errors, PGP_E_P_PACKET_NOT_CONSUMED,
-                       (warn) ? "Warning: Packet was not consumed" :
-                               "Packet was not consumed");
+       PGP_ERROR_1(&stream->errors, PGP_E_P_PACKET_NOT_CONSUMED,
+           "%s", (warn) ? "Warning: Packet was not consumed" :
+           "Packet was not consumed");
        return warn;
 }
 
diff -r 122cc2426805 -r d2a7bbe6399d crypto/external/bsd/netpgp/dist/src/lib/reader.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/reader.c  Sun Mar 04 21:14:55 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/reader.c  Mon Mar 05 02:20:18 2012 +0000
@@ -54,7 +54,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: reader.c,v 1.48 2011/01/01 22:29:00 agc Exp $");
+__RCSID("$NetBSD: reader.c,v 1.49 2012/03/05 02:20:18 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -396,34 +396,34 @@
 
        case END_PGP_MESSAGE:
                if (prev != BEGIN_PGP_MESSAGE) {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                                "Got END PGP MESSAGE, but not after BEGIN");
                }
                break;
 
        case END_PGP_PUBLIC_KEY_BLOCK:
                if (prev != BEGIN_PGP_PUBLIC_KEY_BLOCK) {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                        "Got END PGP PUBLIC KEY BLOCK, but not after BEGIN");
                }
                break;
 
        case END_PGP_PRIVATE_KEY_BLOCK:
                if (prev != BEGIN_PGP_PRIVATE_KEY_BLOCK) {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                        "Got END PGP PRIVATE KEY BLOCK, but not after BEGIN");
                }
                break;
 
        case BEGIN_PGP_MULTI:
        case END_PGP_MULTI:
-               PGP_ERROR(errors, PGP_E_R_UNSUPPORTED,
+               PGP_ERROR_1(errors, PGP_E_R_UNSUPPORTED, "%s",
                        "Multi-part messages are not yet supported");
                break;
 
        case END_PGP_SIGNATURE:
                if (prev != BEGIN_PGP_SIGNATURE) {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                        "Got END PGP SIGNATURE, but not after BEGIN");
                }
                break;
@@ -588,7 +588,7 @@
 
        body = &content.u.cleartext_body;
        if ((hash = calloc(1, sizeof(*hash))) == NULL) {
-               PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+               PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                        "process_dash_escaped: bad alloc");
                return -1;
        }
@@ -615,7 +615,7 @@
        }
 
        if (!hash->init(hash)) {
-               PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
+               PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
                        "can't initialise hash");
                return -1;
        }
@@ -638,8 +638,8 @@
                        if (c != ' ') {
                                /* then this had better be a trailer! */
                                if (c != '-') {
-                                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
-                                               "Bad dash-escaping");
+                                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                                           "%s", "Bad dash-escaping");
                                }
                                for (count = 2; count < 5; ++count) {
                                        if ((c = read_char(stream, dearmour, errors,
@@ -647,8 +647,8 @@
                                                return -1;
                                        }
                                        if (c != '-') {
-                                               PGP_ERROR(errors,
-                                               PGP_E_R_BAD_FORMAT,
+                                               PGP_ERROR_1(errors,
+                                               PGP_E_R_BAD_FORMAT, "%s",
                                                "Bad dash-escaping (2)");
                                        }
                                }
@@ -756,7 +756,8 @@
                int             c;
 
                if ((c = read_char(stream, dearmour, errors, readinfo, cbinfo, 1)) < 0) {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT, "Unexpected EOF");
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                           "%s", "Unexpected EOF");
                        ret = -1;
                        break;
                }
@@ -780,13 +781,17 @@
                                         * then we have seriously malformed
                                         * armour
                                         */
-                                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT, "No colon in armour header");
+                                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                                           "%s", "No colon in armour header");
                                        ret = -1;
                                        break;
                                } else {
                                        if (first &&
                                            !(dearmour->allow_headers_without_gap || dearmour->allow_no_gap)) {
-                                               PGP_ERROR(errors, PGP_E_R_BAD_FORMAT, "No colon in armour header (2)");
+                                               PGP_ERROR_1(errors,
+                                                   PGP_E_R_BAD_FORMAT,
+                                                   "%s", "No colon in"
+                                                   " armour header (2)");
                                                /*
                                                 * then we have a nasty
                                                 * armoured block with no
@@ -802,7 +807,8 @@
                        } else {
                                *s = '\0';
                                if (s[1] != ' ') {
-                                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT, "No space in armour header");
+                                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                                           "%s", "No space in armour header");
                                        ret = -1;
                                        goto end;
                                }
@@ -906,13 +912,14 @@
 
        ret = read4(stream, dearmour, errors, readinfo, cbinfo, &c, &n, &l);
        if (ret < 0) {
-               PGP_ERROR(errors, PGP_E_R_BAD_FORMAT, "Badly formed base64");
+               PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT, "%s",
+                   "Badly formed base64");
                return 0;
        }
        if (n == 3) {
                if (c != '=') {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
-                                       "Badly terminated base64 (2)");
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                           "%s", "Badly terminated base64 (2)");
                        return 0;
                }
                dearmour->buffered = 2;
@@ -920,8 +927,8 @@
                l >>= 2;
        } else if (n == 2) {
                if (c != '=') {
-                       PGP_ERROR(errors, PGP_E_R_BAD_FORMAT,
-                                       "Badly terminated base64 (3)");
+                       PGP_ERROR_1(errors, PGP_E_R_BAD_FORMAT,
+                           "%s", "Badly terminated base64 (3)");
                        return 0;
                }
                dearmour->buffered = 1;
@@ -929,14 +936,14 @@



Home | Main Index | Thread Index | Old Index