1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

* keygen.c (make_backsig): Make sure that the backsig was built

successfully before we try and use it.
This commit is contained in:
David Shaw 2004-06-16 14:43:05 +00:00
parent d25162fa19
commit 3659850b1b
2 changed files with 59 additions and 50 deletions

View File

@ -1,3 +1,8 @@
2004-06-16 David Shaw <dshaw@jabberwocky.com>
* keygen.c (make_backsig): Make sure that the backsig was built
successfully before we try and use it.
2004-06-16 Werner Koch <wk@gnupg.org>
* free-packet.c (copy_secret_key): Get last fix right.

View File

@ -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);
/* 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();
}
if(rc)
log_error("build_packet failed for backsig: %s\n",g10_errstr(rc));
else
{
int mark=1;
{
size_t pktlen=0;
byte *buf=iobuf_get_temp_buffer(backsig_out);
switch(buf[0]&3)
{
case 3:
BUG();
break;
/* 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
{
int mark=1;
case 2:
pktlen =buf[mark++] << 24;
pktlen|=buf[mark++] << 16;
switch(buf[0]&3)
{
case 3:
BUG();
break;
case 1:
pktlen|=buf[mark++] << 8;
case 2:
pktlen =buf[mark++] << 24;
pktlen|=buf[mark++] << 16;
case 0:
pktlen|=buf[mark++];
}
case 1:
pktlen|=buf[mark++] << 8;
buf+=mark;
}
case 0:
pktlen|=buf[mark++];
}
/* now make the binary blob into a subpacket */
build_sig_subpkt(sig,SIGSUBPKT_SIGNATURE,buf,pktlen);
buf+=mark;
}
/* 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;