@@ -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
@@ -2575,8 +2577,8 @@ void Security::set_resuming(bool b)
25752577}
25762578
25772579
2578- X509_NAME::X509_NAME (const char * n, size_t sz)
2579- : name_(0 ), sz_(sz)
2580+ X509_NAME::X509_NAME (const char * n, size_t sz, int pos, int len )
2581+ : name_(0 ), sz_(sz), cnPosition_(pos), cnLen_(len)
25802582{
25812583 if (sz) {
25822584 name_ = NEW_YS char [sz];
@@ -2606,8 +2608,10 @@ size_t X509_NAME::GetLength() const
26062608
26072609
26082610X509::X509 (const char * i, size_t iSz, const char * s, size_t sSz ,
2609- ASN1_STRING *b, ASN1_STRING *a)
2610- : issuer_(i, iSz), subject_(s, sSz ),
2611+ ASN1_STRING *b, ASN1_STRING *a,
2612+ int issPos, int issLen,
2613+ int subPos, int subLen)
2614+ : issuer_(i, iSz, issPos, issLen), subject_(s, sSz , subPos, subLen),
26112615 beforeDate_((char *) b->data, b->length, b->type),
26122616 afterDate_((char *) a->data, a->length, a->type)
26132617{}
@@ -2642,19 +2646,20 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
26422646 if (i < 0 || i >= int (sz_))
26432647 return 0 ;
26442648
2649+ if (i != cnPosition_ || cnLen_ <= 0 ) // only entry currently supported
2650+ return 0 ;
2651+
2652+ if (cnLen_ > int (sz_-i)) // make sure there's room in read buffer
2653+ return 0 ;
2654+
26452655 if (entry_.data )
26462656 ysArrayDelete (entry_.data );
2647- entry_.data = NEW_YS byte[sz_ ]; // max size;
2657+ entry_.data = NEW_YS byte[cnLen_+ 1 ]; // max size;
26482658
2649- memcpy (entry_.data , &name_[i], sz_ - i);
2650- if (entry_.data [sz_ -i - 1 ]) {
2651- entry_.data [sz_ - i] = 0 ;
2652- entry_.length = int (sz_) - i;
2653- }
2654- else
2655- entry_.length = int (sz_) - i - 1 ;
2659+ memcpy (entry_.data , &name_[i], cnLen_);
2660+ entry_.data [cnLen_] = 0 ;
2661+ entry_.length = cnLen_;
26562662 entry_.type = 0 ;
2657-
26582663 return &entry_;
26592664}
26602665
0 commit comments