@@ -1607,7 +1607,9 @@ void SSL_SESSION::CopyX509(X509* x)
16071607
16081608 peerX509_ = NEW_YS X509 (issuer->GetName (), issuer->GetLength (),
16091609 subject->GetName (), subject->GetLength (),
1610- before, after);
1610+ before, after,
1611+ issuer->GetCnPosition (), issuer->GetCnLength (),
1612+ subject->GetCnPosition (), subject->GetCnLength ());
16111613}
16121614
16131615
@@ -2583,8 +2585,8 @@ void Security::set_resuming(bool b)
25832585}
25842586
25852587
2586- X509_NAME::X509_NAME (const char * n, size_t sz)
2587- : name_(0 ), sz_(sz)
2588+ X509_NAME::X509_NAME (const char * n, size_t sz, int pos, int len )
2589+ : name_(0 ), sz_(sz), cnPosition_(pos), cnLen_(len)
25882590{
25892591 if (sz) {
25902592 name_ = NEW_YS char [sz];
@@ -2614,8 +2616,10 @@ size_t X509_NAME::GetLength() const
26142616
26152617
26162618X509::X509 (const char * i, size_t iSz, const char * s, size_t sSz ,
2617- ASN1_STRING *b, ASN1_STRING *a)
2618- : issuer_(i, iSz), subject_(s, sSz ),
2619+ ASN1_STRING *b, ASN1_STRING *a,
2620+ int issPos, int issLen,
2621+ int subPos, int subLen)
2622+ : issuer_(i, iSz, issPos, issLen), subject_(s, sSz , subPos, subLen),
26192623 beforeDate_((char *) b->data, b->length, b->type),
26202624 afterDate_((char *) a->data, a->length, a->type)
26212625{}
@@ -2650,19 +2654,20 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
26502654 if (i < 0 || i >= int (sz_))
26512655 return 0 ;
26522656
2657+ if (i != cnPosition_ || cnLen_ <= 0 ) // only entry currently supported
2658+ return 0 ;
2659+
2660+ if (cnLen_ > int (sz_-i)) // make sure there's room in read buffer
2661+ return 0 ;
2662+
26532663 if (entry_.data )
26542664 ysArrayDelete (entry_.data );
2655- entry_.data = NEW_YS byte[sz_ ]; // max size;
2665+ entry_.data = NEW_YS byte[cnLen_+ 1 ]; // max size;
26562666
2657- memcpy (entry_.data , &name_[i], sz_ - i);
2658- if (entry_.data [sz_ -i - 1 ]) {
2659- entry_.data [sz_ - i] = 0 ;
2660- entry_.length = int (sz_) - i;
2661- }
2662- else
2663- entry_.length = int (sz_) - i - 1 ;
2667+ memcpy (entry_.data , &name_[i], cnLen_);
2668+ entry_.data [cnLen_] = 0 ;
2669+ entry_.length = cnLen_;
26642670 entry_.type = 0 ;
2665-
26662671 return &entry_;
26672672}
26682673
0 commit comments