aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2004-06-16 14:43:05 +0000
committerDavid Shaw <[email protected]>2004-06-16 14:43:05 +0000
commit3659850b1be8ed134793bd970a4358d83d0849c9 (patch)
tree268ebb3ac3fbd42d21f8823fe1a8f076fabf2e1d
parentPreparing an RC. (diff)
downloadgnupg-3659850b1be8ed134793bd970a4358d83d0849c9.tar.gz
gnupg-3659850b1be8ed134793bd970a4358d83d0849c9.zip
* keygen.c (make_backsig): Make sure that the backsig was built
successfully before we try and use it.
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/keygen.c102
2 files changed, 58 insertions, 49 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 99a3d5ccd..a9786a26c 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-16 David Shaw <[email protected]>
+
+ * keygen.c (make_backsig): Make sure that the backsig was built
+ successfully before we try and use it.
+
2004-06-16 Werner Koch <[email protected]>
* free-packet.c (copy_secret_key): Get last fix right.
diff --git a/g10/keygen.c b/g10/keygen.c
index ff415c981..6b1ff98a6 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -551,69 +551,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;