aboutsummaryrefslogtreecommitdiffstats
path: root/g10/plaintext.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-01-20 18:10:35 +0000
committerWerner Koch <[email protected]>1999-01-20 18:10:35 +0000
commit7debff3867c0c087ccae465517aa26e475266427 (patch)
treebcb1ccedb0ee7711cb28a6add0a16a56cf0d0c34 /g10/plaintext.c
parentSee ChangeLog: Tue Jan 19 19:34:58 CET 1999 Werner Koch (diff)
downloadgnupg-7debff3867c0c087ccae465517aa26e475266427.tar.gz
gnupg-7debff3867c0c087ccae465517aa26e475266427.zip
See ChangeLog: Wed Jan 20 18:59:49 CET 1999 Werner Koch
Diffstat (limited to 'g10/plaintext.c')
-rw-r--r--g10/plaintext.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 0dc246939..98c4314ea 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -89,6 +89,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
if( pt->len ) {
+ assert( !clearsig );
for( ; pt->len; pt->len-- ) {
if( (c = iobuf_get(pt->buf)) == -1 ) {
log_error("Problem reading source (%u bytes remaining)\n",
@@ -98,7 +99,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
if( mfx->md )
md_putc(mfx->md, c );
- if( convert && !clearsig && c == '\r' )
+ if( convert && c == '\r' )
continue; /* fixme: this hack might be too simple */
if( fp ) {
if( putc( c, fp ) == EOF ) {
@@ -110,11 +111,11 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
}
}
- else {
+ else if( !clearsig ) {
while( (c = iobuf_get(pt->buf)) != -1 ) {
if( mfx->md )
md_putc(mfx->md, c );
- if( convert && !clearsig && c == '\r' )
+ if( convert && c == '\r' )
continue; /* fixme: this hack might be too simple */
if( fp ) {
if( putc( c, fp ) == EOF ) {
@@ -127,6 +128,47 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
pt->buf = NULL;
}
+ else { /* clear text signature - don't hash the last cr,lf */
+ int state = 0;
+
+ while( (c = iobuf_get(pt->buf)) != -1 ) {
+ if( fp ) {
+ if( putc( c, fp ) == EOF ) {
+ log_error("Error writing to `%s': %s\n",
+ fname, strerror(errno) );
+ rc = G10ERR_WRITE_FILE;
+ goto leave;
+ }
+ }
+ if( !mfx->md )
+ continue;
+ if( state == 2 ) {
+ md_putc(mfx->md, '\r' );
+ md_putc(mfx->md, '\n' );
+ state = 0;
+ }
+ if( !state ) {
+ if( c == '\r' )
+ state = 1;
+ else
+ md_putc(mfx->md, c );
+ }
+ else if( state == 1 ) {
+ if( c == '\n' )
+ state = 2;
+ else {
+ md_putc(mfx->md, '\r' );
+ if( c == '\r' )
+ state = 1;
+ else {
+ state = 0;
+ md_putc(mfx->md, c );
+ }
+ }
+ }
+ }
+ pt->buf = NULL;
+ }
if( fp && fp != stdout && fclose(fp) ) {
log_error("Error closing `%s': %s\n", fname, strerror(errno) );