Module Name: src
Committed By: agc
Date: Fri Nov 20 15:21:18 UTC 2009
Modified Files:
src/crypto/external/bsd/netpgp/dist/src/lib: writer.c
Log Message:
When writing an ascii-armoured message, push the linebreak writer onto
the write function stack for the body of the message as well as the
headers.
This means that an ascii-armoured signed file created by netpgp conforms
to RFC 4880 (and 2440, thanks, moof[1]), and can be verified by gpg now, as
well as netpgp.
[1] Are there any other RFCs which are superceded by their double?
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/crypto/external/bsd/netpgp/dist/src/lib/writer.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/external/bsd/netpgp/dist/src/lib/writer.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/writer.c:1.16 src/crypto/external/bsd/netpgp/dist/src/lib/writer.c:1.17
--- src/crypto/external/bsd/netpgp/dist/src/lib/writer.c:1.16 Fri Nov 20 07:17:07 2009
+++ src/crypto/external/bsd/netpgp/dist/src/lib/writer.c Fri Nov 20 15:21:18 2009
@@ -58,7 +58,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: writer.c,v 1.16 2009/11/20 07:17:07 agc Exp $");
+__RCSID("$NetBSD: writer.c,v 1.17 2009/11/20 15:21:18 agc Exp $");
#endif
#include <sys/types.h>
@@ -650,11 +650,11 @@
linebreak_t *linebreak = __ops_writer_get_arg(writer);
unsigned n;
+printf("in linebreak writer, len %d\n", len);
for (n = 0; n < len; ++n, ++linebreak->pos) {
if (src[n] == '\r' || src[n] == '\n') {
linebreak->pos = 0;
}
-
if (linebreak->pos == BREAKPOS) {
if (!__ops_stacked_write("\r\n", 2, errors, writer)) {
return 0;
@@ -759,18 +759,28 @@
__ops_writer_push_armor_msg(__ops_output_t *output)
{
static const char header[] = "-----BEGIN PGP MESSAGE-----\r\n";
+ linebreak_t *linebreak;
base64_t *base64;
__ops_write(output, header, sizeof(header) - 1);
__ops_write(output, "\r\n", 2);
+ if ((linebreak = calloc(1, sizeof(*linebreak))) == NULL) {
+ (void) fprintf(stderr,
+ "__ops_writer_push_armor_msg: bad lb alloc\n");
+ return;
+ }
+ __ops_writer_push(output, linebreak_writer, NULL,
+ generic_destroyer,
+ linebreak);
if ((base64 = calloc(1, sizeof(*base64))) == NULL) {
- (void) fprintf(stderr, "__ops_writer_push_armor_msg: bad alloc\n");
- } else {
- base64->checksum = CRC24_INIT;
- __ops_writer_push(output, base64_writer,
- armoured_message_finaliser, generic_destroyer,
- base64);
+ (void) fprintf(stderr,
+ "__ops_writer_push_armor_msg: bad alloc\n");
+ return;
}
+ base64->checksum = CRC24_INIT;
+ __ops_writer_push(output, base64_writer,
+ armoured_message_finaliser, generic_destroyer,
+ base64);
}
static unsigned