aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog16
-rw-r--r--g10/g10.c7
-rw-r--r--g10/keygen.c102
-rw-r--r--g10/parse-packet.c4
-rw-r--r--g10/plaintext.c18
-rw-r--r--g10/status.c4
-rw-r--r--g10/status.h8
7 files changed, 100 insertions, 59 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 7333d138d..1a45c5fb8 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,19 @@
+2004-07-15 David Shaw <[email protected]>
+
+ * g10.c (main): Alias --charset as --display-charset to help avoid
+ the continuing confusion and make room for possible changes in
+ devel.
+
+ * parse-packet.c (parse_plaintext): Show the hex value for the
+ literal packet mode since it may not be printable.
+
+ * keygen.c (make_backsig): Make sure that the backsig was built
+ successfully before we try and use it.
+
+ * status.h, status.c (get_status_string), plaintext.c
+ (handle_plaintext): New status tags PLAINTEXT and
+ PLAINTEXT_LENGTH.
+
2004-06-16 Werner Koch <[email protected]>
* free-packet.c (copy_secret_key): Get last fix right.
diff --git a/g10/g10.c b/g10/g10.c
index 915f59cc1..313c00765 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -259,7 +259,7 @@ enum cmd_and_opt_values
oS2KDigest,
oS2KCipher,
oSimpleSKChecksum,
- oCharset,
+ oDisplayCharset,
oNotDashEscaped,
oEscapeFrom,
oNoEscapeFrom,
@@ -477,7 +477,8 @@ static ARGPARSE_OPTS opts[] = {
{ oExportOptions, "export-options",2,"@"},
{ oListOptions, "list-options",2,"@"},
{ oVerifyOptions, "verify-options",2,"@"},
- { oCharset, "charset", 2, "@"},
+ { oDisplayCharset, "display-charset", 2, "@"},
+ { oDisplayCharset, "charset", 2, "@"},
{ oOptions, "options", 2, "@"},
{ oDebug, "debug" ,4|16, "@"},
{ oDebugAll, "debug-all" ,0, "@"},
@@ -2093,7 +2094,7 @@ main( int argc, char **argv )
case oNoSecmemWarn: secmem_set_flags( secmem_get_flags() | 1 ); break;
case oNoPermissionWarn: opt.no_perm_warn=1; break;
case oNoMDCWarn: opt.no_mdc_warn=1; break;
- case oCharset:
+ case oDisplayCharset:
if( set_native_charset( pargs.r.ret_str ) )
log_error(_("%s is not a valid character set\n"),
pargs.r.ret_str);
diff --git a/g10/keygen.c b/g10/keygen.c
index 24a81f128..3b5a409c0 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -651,69 +651,73 @@ make_backsig(PKT_signature *sig, PKT_public_key *pk,
/* get it into a binary packed form. */
IOBUF backsig_out=iobuf_temp();
PACKET backsig_pkt;
- byte *buf;
- size_t pktlen=0;
init_packet(&backsig_pkt);
backsig_pkt.pkttype=PKT_SIGNATURE;
backsig_pkt.pkt.signature=backsig;
- build_packet(backsig_out,&backsig_pkt);
+ rc=build_packet(backsig_out,&backsig_pkt);
free_packet(&backsig_pkt);
- buf=iobuf_get_temp_buffer(backsig_out);
+ if(rc)
+ log_error("build_packet failed for backsig: %s\n",g10_errstr(rc));
+ else
+ {
+ size_t pktlen=0;
+ byte *buf=iobuf_get_temp_buffer(backsig_out);
- /* Remove the packet header */
- if(buf[0]&0x40)
- {
- if(buf[1]<192)
- {
- pktlen=buf[1];
- buf+=2;
- }
- else if(buf[1]<224)
- {
- pktlen=(buf[1]-192)*256;
- pktlen+=buf[2]+192;
- buf+=3;
- }
- else if(buf[1]==255)
- {
- pktlen =buf[2] << 24;
- pktlen|=buf[3] << 16;
- pktlen|=buf[4] << 8;
- pktlen|=buf[5];
- buf+=6;
- }
+ /* Remove the packet header */
+ if(buf[0]&0x40)
+ {
+ if(buf[1]<192)
+ {
+ pktlen=buf[1];
+ buf+=2;
+ }
+ else if(buf[1]<224)
+ {
+ pktlen=(buf[1]-192)*256;
+ pktlen+=buf[2]+192;
+ buf+=3;
+ }
+ else if(buf[1]==255)
+ {
+ pktlen =buf[2] << 24;
+ pktlen|=buf[3] << 16;
+ pktlen|=buf[4] << 8;
+ pktlen|=buf[5];
+ buf+=6;
+ }
+ else
+ BUG();
+ }
else
- BUG();
- }
- else
- {
- int mark=1;
+ {
+ int mark=1;
- switch(buf[0]&3)
- {
- case 3:
- BUG();
- break;
+ switch(buf[0]&3)
+ {
+ case 3:
+ BUG();
+ break;
- case 2:
- pktlen =buf[mark++] << 24;
- pktlen|=buf[mark++] << 16;
+ case 2:
+ pktlen =buf[mark++] << 24;
+ pktlen|=buf[mark++] << 16;
- case 1:
- pktlen|=buf[mark++] << 8;
+ case 1:
+ pktlen|=buf[mark++] << 8;
- case 0:
- pktlen|=buf[mark++];
- }
+ case 0:
+ pktlen|=buf[mark++];
+ }
- buf+=mark;
- }
+ buf+=mark;
+ }
- /* now make the binary blob into a subpacket */
- build_sig_subpkt(sig,SIGSUBPKT_SIGNATURE,buf,pktlen);
+ /* now make the binary blob into a subpacket */
+ build_sig_subpkt(sig,SIGSUBPKT_SIGNATURE,buf,pktlen);
- iobuf_close(backsig_out);
+ iobuf_close(backsig_out);
+ }
}
return rc;
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 56a717725..8b3744af1 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -2155,8 +2155,8 @@ parse_plaintext( IOBUF inp, int pkttype, unsigned long pktlen,
if( list_mode ) {
printf(":literal data packet:\n"
- "\tmode %c, created %lu, name=\"",
- mode >= ' ' && mode <'z'? mode : '?',
+ "\tmode %c (%X), created %lu, name=\"",
+ mode >= ' ' && mode <'z'? mode : '?', mode,
(ulong)pt->timestamp );
for(p=pt->name,i=0; i < namelen; p++, i++ ) {
if( *p >= ' ' && *p <= 'z' )
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 26a5cad3b..66d9d8e96 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -61,6 +61,24 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
int filetype = 0xfff;
#endif
+ /* Let people know what the plaintext info is. This allows the
+ receiving program to try and do something different based on
+ the format code (say, recode UTF-8 to local). */
+ if(!nooutput && is_status_enabled())
+ {
+ char status[20];
+
+ sprintf(status,"%X %lu ",(byte)pt->mode,(ulong)pt->timestamp);
+ write_status_text_and_buffer(STATUS_PLAINTEXT,
+ status,pt->name,pt->namelen,0);
+
+ if(!pt->is_partial)
+ {
+ sprintf(status,"%lu",(ulong)pt->len);
+ write_status_text(STATUS_PLAINTEXT_LENGTH,status);
+ }
+ }
+
/* create the filename as C string */
if( nooutput )
;
diff --git a/g10/status.c b/g10/status.c
index b6e91740d..ef0cc8cbb 100644
--- a/g10/status.c
+++ b/g10/status.c
@@ -1,5 +1,5 @@
/* status.c
- * Copyright (C) 1998, 1999, 2000, 2001, 2002,
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
* 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
@@ -153,6 +153,8 @@ get_status_string ( int no )
case STATUS_REVKEYSIG : s = "REVKEYSIG"; break;
case STATUS_ATTRIBUTE : s = "ATTRIBUTE"; break;
case STATUS_CARDCTRL : s = "CARDCTRL"; break;
+ case STATUS_PLAINTEXT : s = "PLAINTEXT"; break;
+ case STATUS_PLAINTEXT_LENGTH:s = "PLAINTEXT_LENGTH"; break;
default: s = "?"; break;
}
return s;
diff --git a/g10/status.h b/g10/status.h
index 63f01b9a4..ee282662a 100644
--- a/g10/status.h
+++ b/g10/status.h
@@ -1,5 +1,6 @@
/* status.h
- * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
+ * 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -20,7 +21,6 @@
#ifndef G10_STATUS_H
#define G10_STATUS_H
-
#define STATUS_ENTER 1
#define STATUS_LEAVE 2
#define STATUS_ABORT 3
@@ -29,7 +29,6 @@
#define STATUS_BADSIG 5
#define STATUS_ERRSIG 6
-
#define STATUS_BADARMOR 7
#define STATUS_RSA_OR_IDEA 8
@@ -102,6 +101,8 @@
#define STATUS_REVKEYSIG 70
#define STATUS_CARDCTRL 71
#define STATUS_NEWSIG 72
+#define STATUS_PLAINTEXT 73
+#define STATUS_PLAINTEXT_LENGTH 74
/*-- status.c --*/
void set_status_fd ( int fd );
@@ -129,5 +130,4 @@ int cpr_get_answer_okay_cancel (const char *keyword,
const char *prompt,
int def_answer);
-
#endif /*G10_STATUS_H*/