@@ -1555,7 +1555,9 @@ void SSL_SESSION::CopyX509(X509* x)
15551555
15561556 peerX509_ = NEW_YS X509 (issuer->GetName (), issuer->GetLength (),
15571557 subject->GetName (), subject->GetLength (), (const char *) before->data ,
1558- before->length , (const char *) after->data , after->length );
1558+ before->length , (const char *) after->data , after->length ,
1559+ issuer->GetCnPosition (), issuer->GetCnLength (),
1560+ subject->GetCnPosition (), subject->GetCnLength ());
15591561}
15601562
15611563
@@ -2472,8 +2474,8 @@ void Security::set_resuming(bool b)
24722474}
24732475
24742476
2475- X509_NAME::X509_NAME (const char * n, size_t sz)
2476- : name_(0 ), sz_(sz)
2477+ X509_NAME::X509_NAME (const char * n, size_t sz, int pos, int len )
2478+ : name_(0 ), sz_(sz), cnPosition_(pos), cnLen_(len)
24772479{
24782480 if (sz) {
24792481 name_ = NEW_YS char [sz];
@@ -2503,8 +2505,9 @@ size_t X509_NAME::GetLength() const
25032505
25042506
25052507X509::X509 (const char * i, size_t iSz, const char * s, size_t sSz ,
2506- const char * b, int bSz, const char * a, int aSz)
2507- : issuer_(i, iSz), subject_(s, sSz ),
2508+ const char * b, int bSz, const char * a, int aSz, int issPos,
2509+ int issLen, int subPos, int subLen)
2510+ : issuer_(i, iSz, issPos, issLen), subject_(s, sSz , subPos, subLen),
25082511 beforeDate_ (b, bSz), afterDate_(a, aSz)
25092512{}
25102513
@@ -2538,17 +2541,19 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
25382541 if (i < 0 || i >= int (sz_))
25392542 return 0 ;
25402543
2544+ if (i != cnPosition_ || cnLen_ <= 0 ) // only entry currently supported
2545+ return 0 ;
2546+
2547+ if (cnLen_ > int (sz_-i)) // make sure there's room in read buffer
2548+ return 0 ;
2549+
25412550 if (entry_.data )
25422551 ysArrayDelete (entry_.data );
2543- entry_.data = NEW_YS byte[sz_ ]; // max size;
2552+ entry_.data = NEW_YS byte[cnLen_+ 1 ]; // max size;
25442553
2545- memcpy (entry_.data , &name_[i], sz_ - i);
2546- if (entry_.data [sz_ -i - 1 ]) {
2547- entry_.data [sz_ - i] = 0 ;
2548- entry_.length = int (sz_) - i;
2549- }
2550- else
2551- entry_.length = int (sz_) - i - 1 ;
2554+ memcpy (entry_.data , &name_[i], cnLen_);
2555+ entry_.data [cnLen_] = 0 ;
2556+ entry_.length = cnLen_;
25522557 entry_.type = 0 ;
25532558
25542559 return &entry_;
0 commit comments