@@ -1607,7 +1607,9 @@ void SSL_SESSION::CopyX509(X509* x)
1607
1607
1608
1608
peerX509_ = NEW_YS X509 (issuer->GetName (), issuer->GetLength (),
1609
1609
subject->GetName (), subject->GetLength (),
1610
- before, after);
1610
+ before, after,
1611
+ issuer->GetCnPosition (), issuer->GetCnLength (),
1612
+ subject->GetCnPosition (), subject->GetCnLength ());
1611
1613
}
1612
1614
1613
1615
@@ -2575,8 +2577,8 @@ void Security::set_resuming(bool b)
2575
2577
}
2576
2578
2577
2579
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)
2580
2582
{
2581
2583
if (sz) {
2582
2584
name_ = NEW_YS char [sz];
@@ -2606,8 +2608,10 @@ size_t X509_NAME::GetLength() const
2606
2608
2607
2609
2608
2610
X509::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),
2611
2615
beforeDate_((char *) b->data, b->length, b->type),
2612
2616
afterDate_((char *) a->data, a->length, a->type)
2613
2617
{}
@@ -2642,19 +2646,20 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
2642
2646
if (i < 0 || i >= int (sz_))
2643
2647
return 0 ;
2644
2648
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
+
2645
2655
if (entry_.data )
2646
2656
ysArrayDelete (entry_.data );
2647
- entry_.data = NEW_YS byte[sz_ ]; // max size;
2657
+ entry_.data = NEW_YS byte[cnLen_+ 1 ]; // max size;
2648
2658
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_;
2656
2662
entry_.type = 0 ;
2657
-
2658
2663
return &entry_;
2659
2664
}
2660
2665
0 commit comments