Changeset 34

Show
Ignore:
Timestamp:
02/22/05 15:55:54
Author:
ben
Message:

Detach region management from packet tags.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openpgpsdk/trunk/src/packet-parse.c

    r33 r34  
    1212#include <string.h> 
    1313 
     14typedef struct ops_region 
     15    { 
     16    struct ops_region *parent; 
     17    unsigned length; 
     18    unsigned length_read; 
     19    } ops_region_t; 
     20 
     21static void init_subregion(ops_region_t *subregion,ops_region_t *region) 
     22    { 
     23    memset(subregion,'\0',sizeof *subregion); 
     24    subregion->parent=region; 
     25    } 
     26 
    1427#define CB(t,pc)        do { (pc)->tag=(t); cb(pc); } while(0) 
    1528#define C               content.content 
     
    88101 */ 
    89102static int limited_read(unsigned char *dest,unsigned length, 
    90                         ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     103                        ops_region_t *region,ops_packet_reader_t *reader, 
    91104                        ops_packet_parse_callback_t *cb) 
    92105    { 
    93106    ops_parser_content_t content; 
    94107 
    95     if(ptag->length_read+length > ptag->length) 
     108    if(region->length_read+length > region->length) 
    96109        ERR("Not enough data left"); 
    97110 
     
    99112        ERR("Read failed"); 
    100113 
    101     ptag->length_read+=length; 
     114    do 
     115        { 
     116        region->length_read+=length; 
     117        assert(!region->parent || region->length <= region->parent->length); 
     118        } 
     119    while((region=region->parent)); 
    102120 
    103121    return 1; 
     
    116134 * \return              1 on success, 0 on error (calls the cb with #OPS_PARSER_ERROR in #limited_read). 
    117135 */ 
    118 static int limited_skip(unsigned length,ops_ptag_t *ptag
     136static int limited_skip(unsigned length,ops_region_t *region
    119137                        ops_packet_reader_t *reader, 
    120138                        ops_packet_parse_callback_t *cb) 
     
    125143        { 
    126144        int n=length%8192; 
    127         if(!limited_read(buf,n,ptag,reader,cb)) 
     145        if(!limited_read(buf,n,region,reader,cb)) 
    128146            return 0; 
    129147        length-=n; 
     
    149167 */ 
    150168static int limited_read_scalar(unsigned *dest,unsigned length, 
    151                                ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     169                               ops_region_t *region, 
     170                               ops_packet_reader_t *reader, 
    152171                               ops_packet_parse_callback_t *cb) 
    153172    { 
     
    156175    int n; 
    157176 
    158     if(!limited_read(c,length,ptag,reader,cb)) 
     177    if(!limited_read(c,length,region,reader,cb)) 
    159178        return 0; 
    160179 
     
    183202 * \see RFC2440bis-12 3.5 
    184203 */ 
    185 static int limited_read_time(time_t *dest,ops_ptag_t *ptag
     204static int limited_read_time(time_t *dest,ops_region_t *region
    186205                             ops_packet_reader_t *reader, 
    187206                             ops_packet_parse_callback_t *cb) 
    188207    { 
    189     return limited_read_scalar((unsigned *)dest,4,ptag,reader,cb); 
     208    return limited_read_scalar((unsigned *)dest,4,region,reader,cb); 
    190209    } 
    191210 
     
    212231 * \see RFC2440bis-12 3.2 
    213232 */ 
    214 static int limited_read_mpi(BIGNUM **pbn,ops_ptag_t *ptag
     233static int limited_read_mpi(BIGNUM **pbn,ops_region_t *region
    215234                            ops_packet_reader_t *reader, 
    216235                            ops_packet_parse_callback_t *cb) 
     
    223242    ops_parser_content_t content; 
    224243 
    225     if(!limited_read_scalar(&length,2,ptag,reader,cb)) 
     244    if(!limited_read_scalar(&length,2,region,reader,cb)) 
    226245        return 0; 
    227246 
     
    232251 
    233252    assert(length <= 8192); 
    234     if(!limited_read(buf,length,ptag,reader,cb)) 
     253    if(!limited_read(buf,length,region,reader,cb)) 
    235254        return 0; 
    236255 
     
    259278 * \see ops_ptag_t 
    260279 */ 
    261 static int limited_read_new_length(unsigned *length,ops_ptag_t *ptag
     280static int limited_read_new_length(unsigned *length,ops_region_t *region
    262281                                   ops_packet_reader_t *reader, 
    263282                                   ops_packet_parse_callback_t *cb) 
     
    265284    unsigned char c[1]; 
    266285 
    267     if(!limited_read(c,1,ptag,reader,cb)) 
     286    if(!limited_read(c,1,region,reader,cb)) 
    268287        return 0; 
    269288    if(c[0] < 192) 
     
    276295        unsigned t=(c[0]-192) << 8; 
    277296 
    278         if(!limited_read(c,1,ptag,reader,cb)) 
     297        if(!limited_read(c,1,region,reader,cb)) 
    279298            return 0; 
    280299        *length=t+c[1]+192; 
    281300        return 1; 
    282301        } 
    283     return limited_read_scalar(length,4,ptag,reader,cb); 
     302    return limited_read_scalar(length,4,region,reader,cb); 
    284303    } 
    285304 
     
    297316 * \see RFC2440bis-12 5.5.2 
    298317 */ 
    299 static int parse_public_key(ops_ptag_t *ptag,ops_packet_reader_t *reader, 
    300                              ops_packet_parse_callback_t *cb) 
     318static int parse_public_key(ops_content_tag_t tag,ops_region_t *region, 
     319                            ops_packet_reader_t *reader, 
     320                            ops_packet_parse_callback_t *cb) 
    301321    { 
    302322    ops_parser_content_t content; 
    303323    unsigned char c[1]; 
    304324 
    305     assert (ptag->length_read == 0);  /* We should not have read anything so far */ 
    306  
    307     if(!limited_read(c,1,ptag,reader,cb)) 
     325    assert (region->length_read == 0);  /* We should not have read anything so far */ 
     326 
     327    if(!limited_read(c,1,region,reader,cb)) 
    308328        return 0; 
    309329    C.public_key.version=c[0]; 
     
    315335        ERR1("Bad public key version (0x%02x)",C.public_key.version); 
    316336 
    317     if(!limited_read_time(&C.public_key.creation_time,ptag,reader,cb)) 
     337    if(!limited_read_time(&C.public_key.creation_time,region,reader,cb)) 
    318338        return 0; 
    319339 
    320340    C.public_key.days_valid=0; 
    321341    if(C.public_key.version == 3 
    322        && !limited_read_scalar(&C.public_key.days_valid,2,ptag,reader, 
     342       && !limited_read_scalar(&C.public_key.days_valid,2,region,reader, 
    323343                               cb)) 
    324344        return 0; 
    325345 
    326     if(!limited_read(c,1,ptag,reader,cb)) 
     346    if(!limited_read(c,1,region,reader,cb)) 
    327347        return 0; 
    328348 
     
    332352        { 
    333353    case OPS_PKA_DSA: 
    334         if(!limited_read_mpi(&C.public_key.key.dsa.p,ptag,reader,cb) 
    335            || !limited_read_mpi(&C.public_key.key.dsa.q,ptag,reader,cb) 
    336            || !limited_read_mpi(&C.public_key.key.dsa.g,ptag,reader,cb) 
    337            || !limited_read_mpi(&C.public_key.key.dsa.y,ptag,reader,cb)) 
     354        if(!limited_read_mpi(&C.public_key.key.dsa.p,region,reader,cb) 
     355           || !limited_read_mpi(&C.public_key.key.dsa.q,region,reader,cb) 
     356           || !limited_read_mpi(&C.public_key.key.dsa.g,region,reader,cb) 
     357           || !limited_read_mpi(&C.public_key.key.dsa.y,region,reader,cb)) 
    338358            return 0; 
    339359        break; 
     
    342362    case OPS_PKA_RSA_ENCRYPT_ONLY: 
    343363    case OPS_PKA_RSA_SIGN_ONLY: 
    344         if(!limited_read_mpi(&C.public_key.key.rsa.n,ptag,reader,cb) 
    345            || !limited_read_mpi(&C.public_key.key.rsa.e,ptag,reader,cb)) 
     364        if(!limited_read_mpi(&C.public_key.key.rsa.n,region,reader,cb) 
     365           || !limited_read_mpi(&C.public_key.key.rsa.e,region,reader,cb)) 
    346366            return 0; 
    347367        break; 
    348368 
    349369    case OPS_PKA_ELGAMAL: 
    350         if(!limited_read_mpi(&C.public_key.key.elgamel.p,ptag,reader,cb) 
    351            || !limited_read_mpi(&C.public_key.key.elgamel.g,ptag,reader,cb) 
    352            || !limited_read_mpi(&C.public_key.key.elgamel.y,ptag,reader,cb)) 
     370        if(!limited_read_mpi(&C.public_key.key.elgamel.p,region,reader,cb) 
     371           || !limited_read_mpi(&C.public_key.key.elgamel.g,region,reader,cb) 
     372           || !limited_read_mpi(&C.public_key.key.elgamel.y,region,reader,cb)) 
    353373            return 0; 
    354374        break; 
     
    358378        } 
    359379 
    360     if(ptag->length_read != ptag->length) 
    361         ERR1("Unconsumed data (%d)", ptag->length-ptag->length_read); 
    362  
    363     CB(ptag->content_tag,&content); 
     380    if(region->length_read != region->length) 
     381        ERR1("Unconsumed data (%d)", region->length-region->length_read); 
     382 
     383    CB(tag,&content); 
    364384 
    365385    return 1; 
     
    383403 * \see RFC2440bis-12 5.11 
    384404 */ 
    385 static int parse_user_id(ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     405static int parse_user_id(ops_region_t *region,ops_packet_reader_t *reader, 
    386406                         ops_packet_parse_callback_t *cb) 
    387407    { 
    388408    ops_parser_content_t content; 
    389409 
    390     assert (ptag->length_read == 0);  /* We should not have read anything so far */ 
    391  
    392     assert(ptag->length); 
    393     C.user_id.user_id=malloc(ptag->length+1);  /* XXX should we not like check malloc's return value? */ 
    394     if(!limited_read(C.user_id.user_id,ptag->length,ptag,reader,cb)) 
    395         return 0; 
    396     C.user_id.user_id[ptag->length] = 0; /* terminate the string */ 
     410    assert (region->length_read == 0);  /* We should not have read anything so far */ 
     411 
     412    assert(region->length); 
     413    C.user_id.user_id=malloc(region->length+1);  /* XXX should we not like check malloc's return value? */ 
     414    if(!limited_read(C.user_id.user_id,region->length,region,reader,cb)) 
     415        return 0; 
     416    C.user_id.user_id[region->length] = 0; /* terminate the string */ 
    397417 
    398418    CB(OPS_PTAG_CT_USER_ID,&content); 
     
    414434 * \see RFC2440bis-12 5.2.2 
    415435 */ 
    416 static int parse_v3_signature(ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     436static int parse_v3_signature(ops_region_t *region,ops_packet_reader_t *reader, 
    417437                              ops_packet_parse_callback_t *cb) 
    418438    { 
     
    420440    ops_parser_content_t content; 
    421441 
    422     assert (ptag->length_read == 0);  /* We should not have read anything so far */ 
     442    assert(region->length_read == 0);  /* We should not have read anything so far */ 
    423443 
    424444    C.signature.version=OPS_SIG_V3; 
    425445 
    426446    /* hash info length */ 
    427     if(!limited_read(c,1,ptag,reader,cb)) 
     447    if(!limited_read(c,1,region,reader,cb)) 
    428448        return 0; 
    429449    if(c[0] != 5) 
    430450        ERR("bad hash info length"); 
    431451 
    432     if(!limited_read(c,1,ptag,reader,cb)) 
     452    if(!limited_read(c,1,region,reader,cb)) 
    433453        return 0; 
    434454    C.signature.type=c[0]; 
    435455    /* XXX: check signature type */ 
    436456 
    437     if(!limited_read_time(&C.signature.creation_time,ptag,reader,cb)) 
    438         return 0; 
    439  
    440     if(!limited_read(C.signature.signer_id,8,ptag,reader,cb)) 
    441         return 0; 
    442  
    443     if(!limited_read(c,1,ptag,reader,cb)) 
     457    if(!limited_read_time(&C.signature.creation_time,region,reader,cb)) 
     458        return 0; 
     459 
     460    if(!limited_read(C.signature.signer_id,8,region,reader,cb)) 
     461        return 0; 
     462 
     463    if(!limited_read(c,1,region,reader,cb)) 
    444464        return 0; 
    445465    C.signature.key_algorithm=c[0]; 
    446466    /* XXX: check algorithm */ 
    447467 
    448     if(!limited_read(c,1,ptag,reader,cb)) 
     468    if(!limited_read(c,1,region,reader,cb)) 
    449469        return 0; 
    450470    C.signature.hash_algorithm=c[0]; 
    451471    /* XXX: check algorithm */ 
    452472     
    453     if(!limited_read(C.signature.hash2,2,ptag,reader,cb)) 
     473    if(!limited_read(C.signature.hash2,2,region,reader,cb)) 
    454474        return 0; 
    455475 
     
    457477        { 
    458478    case OPS_PKA_RSA: 
    459         if(!limited_read_mpi(&C.signature.signature.rsa.sig,ptag,reader,cb)) 
     479        if(!limited_read_mpi(&C.signature.signature.rsa.sig,region,reader,cb)) 
    460480            return 0; 
    461481        break; 
    462482 
    463483    case OPS_PKA_DSA: 
    464         if(!limited_read_mpi(&C.signature.signature.dsa.r,ptag,reader,cb) 
    465            || !limited_read_mpi(&C.signature.signature.dsa.s,ptag,reader,cb)) 
     484        if(!limited_read_mpi(&C.signature.signature.dsa.r,region,reader,cb) 
     485           || !limited_read_mpi(&C.signature.signature.dsa.s,region,reader,cb)) 
    466486            return 0; 
    467487        break; 
     
    471491        } 
    472492 
    473     if(ptag->length_read != ptag->length) 
    474         ERR1("Unconsumed data (%d)", ptag->length-ptag->length_read); 
     493    if(region->length_read != region->length) 
     494        ERR1("Unconsumed data (%d)",region->length-region->length_read); 
    475495 
    476496    CB(OPS_PTAG_CT_SIGNATURE,&content); 
     
    495515 * \see RFC2440bis-12 5.2.3 
    496516 */ 
    497 static int parse_one_signature_subpacket(ops_ptag_t *ptag
     517static int parse_one_signature_subpacket(ops_region_t *region
    498518                                         ops_packet_reader_t *reader, 
    499519                                         ops_packet_parse_callback_t *cb, 
    500520                                         ops_parse_packet_options_t *opt) 
    501521    { 
    502     ops_ptag_t subptag
     522    ops_region_t subregion
    503523    char c[1]; 
    504524    ops_parser_content_t content; 
    505525    unsigned t8,t7; 
    506526 
    507     memset(&subptag,'\0',sizeof subptag); 
    508     if(!limited_read_new_length(&subptag.length,ptag,reader,cb)) 
    509         return 0; 
    510  
    511     if(!limited_read(c,1,&subptag,reader,cb)) 
     527    init_subregion(&subregion,region); 
     528    if(!limited_read_new_length(&subregion.length,region,reader,cb)) 
     529        return 0; 
     530 
     531    if(!limited_read(c,1,&subregion,reader,cb)) 
    512532        return 0; 
    513533 
     
    517537    content.critical=c[0] >> 7; 
    518538    content.tag=OPS_PTAG_SIGNATURE_SUBPACKET_BASE+(c[0]&0x7f); 
     539 
     540    /* Application wants it delivered raw */ 
    519541    if(opt->ss_raw[t8]&t7) 
    520542        { 
    521543        C.ss_raw.tag=content.tag; 
    522         C.ss_raw.length=subptag.length-1; 
     544        C.ss_raw.length=subregion.length-1; 
    523545        C.ss_raw.raw=malloc(C.ss_raw.length); 
    524         if(!limited_read(C.ss_raw.raw,C.ss_raw.length,&subptag,reader,cb)) 
    525             return 0; 
    526         ptag->length_read+=subptag.length; 
     546        if(!limited_read(C.ss_raw.raw,C.ss_raw.length,&subregion,reader,cb)) 
     547            return 0; 
    527548        CB(OPS_PTAG_RAW_SS,&content); 
    528549        return 1; 
    529550        } 
     551 
     552    /* Application doesn't want it delivered parsed */ 
    530553    if(!(opt->ss_parsed[t8]&t7)) 
    531554        { 
    532555        if(content.critical) 
    533556            ERR1("Critical signature subpacket ignored (%d)",c[0]&0x7f); 
    534         if(!limited_skip(subptag.length-1,&subptag,reader,cb)) 
    535             return 0; 
    536         printf("skipped %d length %d\n",c[0]&0x7f,subptag.length); 
    537         ptag->length_read+=subptag.length; 
     557        if(!limited_skip(subregion.length-1,&subregion,reader,cb)) 
     558            return 0; 
     559        printf("skipped %d length %d\n",c[0]&0x7f,subregion.length); 
    538560        return 1; 
    539561        } 
     
    543565    case OPS_PTAG_SS_CREATION_TIME: 
    544566    case OPS_PTAG_SS_EXPIRATION_TIME: 
    545         if(!limited_read_time(&C.ss_time.time,&subptag,reader,cb)) 
     567        if(!limited_read_time(&C.ss_time.time,&subregion,reader,cb)) 
    546568            return 0; 
    547569        break; 
    548570 
    549571    case OPS_PTAG_SS_TRUST: 
    550         if(!limited_read(&C.ss_trust.level,1,&subptag,reader,cb) 
    551            || !limited_read(&C.ss_trust.level,1,&subptag,reader,cb)) 
     572        if(!limited_read(&C.ss_trust.level,1,&subregion,reader,cb) 
     573           || !limited_read(&C.ss_trust.level,1,&subregion,reader,cb)) 
    552574            return 0; 
    553575        break; 
     
    557579        } 
    558580 
    559     if(subptag.length_read != subptag.length) 
    560         ERR1("Unconsumed data (%d)", subptag.length-subptag.length_read); 
     581    if(subregion.length_read != subregion.length) 
     582        ERR1("Unconsumed data (%d)", subregion.length-subregion.length_read); 
    561583  
    562     ptag->length_read+=subptag.length; 
    563584    cb(&content); 
    564585 
     
    581602 * \see RFC2440bis-12 5.2.3 
    582603 */ 
    583 static int parse_signature_subpackets(ops_ptag_t *ptag
     604static int parse_signature_subpackets(ops_region_t *region
    584605                                      ops_packet_reader_t *reader, 
    585606                                      ops_packet_parse_callback_t *cb, 
    586607                                      ops_parse_packet_options_t *opt) 
    587608    { 
    588     ops_ptag_t subptag; 
    589  
    590     memset(&subptag,'\0',sizeof subptag); 
    591     if(!limited_read_scalar(&subptag.length,2,ptag,reader,cb)) 
    592         return 0; 
    593  
    594     while(subptag.length_read < subptag.length) 
    595         if(!parse_one_signature_subpacket(&subptag,reader,cb,opt)) 
    596             { 
    597             ptag->length_read+=subptag.length_read; 
    598             return 0; 
    599             } 
    600  
    601     assert(subptag.length_read == subptag.length);  /* XXX: this should not be an assert but a parse error.  It's not 
     609    ops_region_t subregion; 
     610 
     611    init_subregion(&subregion,region); 
     612    if(!limited_read_scalar(&subregion.length,2,region,reader,cb)) 
     613        return 0; 
     614 
     615    while(subregion.length_read < subregion.length) 
     616        if(!parse_one_signature_subpacket(&subregion,reader,cb,opt)) 
     617            return 0; 
     618 
     619    assert(subregion.length_read == subregion.length);  /* XXX: this should not be an assert but a parse error.  It's not 
    602620                                                       our fault if the packet is inconsistent with itself. */ 
    603621 
    604     ptag->length_read+=subptag.length_read; 
    605  
    606622    return 1; 
    607623    } 
     
    620636 * \see RFC2440bis-12 5.2.3 
    621637 */ 
    622 static int parse_v4_signature(ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     638static int parse_v4_signature(ops_region_t *region,ops_packet_reader_t *reader, 
    623639                              ops_packet_parse_callback_t *cb, 
    624640                              ops_parse_packet_options_t *opt) 
     
    629645    C.signature.version=OPS_SIG_V4; 
    630646 
    631     if(!limited_read(c,1,ptag,reader,cb)) 
     647    if(!limited_read(c,1,region,reader,cb)) 
    632648        return 0; 
    633649    C.signature.type=c[0]; 
    634650    /* XXX: check signature type */ 
    635651 
    636     if(!limited_read(c,1,ptag,reader,cb)) 
     652    if(!limited_read(c,1,region,reader,cb)) 
    637653        return 0; 
    638654    C.signature.key_algorithm=c[0]; 
    639655    /* XXX: check algorithm */ 
    640656 
    641     if(!limited_read(c,1,ptag,reader,cb)) 
     657    if(!limited_read(c,1,region,reader,cb)) 
    642658        return 0; 
    643659    C.signature.hash_algorithm=c[0]; 
    644660    /* XXX: check algorithm */ 
    645661     
    646     if(!parse_signature_subpackets(ptag,reader,cb,opt)) 
    647         return 0; 
    648  
    649     if(!parse_signature_subpackets(ptag,reader,cb,opt)) 
    650         return 0; 
    651  
    652      
    653  
    654     if(!limited_read(C.signature.hash2,2,ptag,reader,cb)) 
     662    if(!parse_signature_subpackets(region,reader,cb,opt)) 
     663        return 0; 
     664 
     665    if(!parse_signature_subpackets(region,reader,cb,opt)) 
     666        return 0; 
     667 
     668    if(!limited_read(C.signature.hash2,2,region,reader,cb)) 
    655669        return 0; 
    656670 
     
    658672        { 
    659673    case OPS_PKA_RSA: 
    660         if(!limited_read_mpi(&C.signature.signature.rsa.sig,ptag,reader,cb)) 
     674        if(!limited_read_mpi(&C.signature.signature.rsa.sig,region,reader,cb)) 
    661675            return 0; 
    662676        break; 
    663677 
    664678    case OPS_PKA_DSA: 
    665         if(!limited_read_mpi(&C.signature.signature.dsa.r,ptag,reader,cb) 
    666            || !limited_read_mpi(&C.signature.signature.dsa.s,ptag,reader,cb)) 
     679        if(!limited_read_mpi(&C.signature.signature.dsa.r,region,reader,cb) 
     680           || !limited_read_mpi(&C.signature.signature.dsa.s,region,reader,cb)) 
    667681            return 0; 
    668682        break; 
     
    672686        } 
    673687 
    674     if(ptag->length_read != ptag->length) 
    675         ERR1("Unconsumed data (%d)", ptag->length-ptag->length_read); 
     688    if(region->length_read != region->length) 
     689        ERR1("Unconsumed data (%d)",region->length-region->length_read); 
    676690 
    677691    CB(OPS_PTAG_CT_SIGNATURE,&content); 
     
    691705 * \return              1 on success, 0 on error 
    692706 */ 
    693 static int parse_signature(ops_ptag_t *ptag,ops_packet_reader_t *reader, 
     707static int parse_signature(ops_region_t *region,ops_packet_reader_t *reader, 
    694708                           ops_packet_parse_callback_t *cb, 
    695709                           ops_parse_packet_options_t *opt) 
     
    698712    ops_parser_content_t content; 
    699713 
    700     if(!limited_read(c,1,ptag,reader,cb)) 
     714    if(!limited_read(c,1,region,reader,cb)) 
    701715        return 0; 
    702716 
     
    704718    /* XXX: are there v2 signatures? - Peter */ 
    705719    if(c[0] == 2 || c[0] == 3) 
    706         return parse_v3_signature(ptag,reader,cb); 
     720        return parse_v3_signature(region,reader,cb); 
    707721    else if(c[0] == 4) 
    708         return parse_v4_signature(ptag,reader,cb,opt); 
     722        return parse_v4_signature(region,reader,cb,opt); 
    709723    ERR1("Bad signature version (%d)",c[0]); 
    710724    } 
     
    728742    ops_parser_content_t content; 
    729743    int r; 
     744    ops_region_t region; 
    730745 
    731746    ret=reader(ptag,1); 
     
    773788        } 
    774789 
    775     C.ptag.length_read=0; 
    776790    CB(OPS_PARSER_PTAG,&content); 
    777791 
     792    init_subregion(&region,NULL); 
     793    region.length=C.ptag.length; 
    778794    switch(C.ptag.content_tag) 
    779795        { 
    780796    case OPS_PTAG_CT_SIGNATURE: 
    781         r=parse_signature(&C.ptag,reader,cb,opt); 
     797        r=parse_signature(&region,reader,cb,opt); 
    782798        break; 
    783799 
    784800    case OPS_PTAG_CT_PUBLIC_KEY: 
    785801    case OPS_PTAG_CT_PUBLIC_SUBKEY: 
    786         r=parse_public_key(&C.ptag,reader,cb); 
     802        r=parse_public_key(C.ptag.content_tag,&region,reader,cb); 
    787803        break; 
    788804 
    789805    case OPS_PTAG_CT_USER_ID: 
    790         r=parse_user_id(&C.ptag,reader,cb); 
     806        r=parse_user_id(&region,reader,cb); 
    791807        break; 
    792808 
  • openpgpsdk/trunk/src/packet.h

    r33 r34  
    158158                                          length information, not at the same moment we create the packet tag structure. 
    159159                                          Only defined if #length_read is set. */  /* XXX: Ben, is this correct? */ 
    160     unsigned          length_read;    /*!< How much bytes of this packet we have read so far - for internal use 
    161                                         only. */ 
     160    //    unsigned            length_read;    /*!< How much bytes of this packet we have read so far - for internal use 
     161    //                                          only. */ 
    162162    } ops_ptag_t; 
    163163