@@ -1555,7 +1555,9 @@ void SSL_SESSION::CopyX509(X509* x)
1555
1555
1556
1556
peerX509_ = NEW_YS X509 (issuer->GetName (), issuer->GetLength (),
1557
1557
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 ());
1559
1561
}
1560
1562
1561
1563
@@ -2472,8 +2474,8 @@ void Security::set_resuming(bool b)
2472
2474
}
2473
2475
2474
2476
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)
2477
2479
{
2478
2480
if (sz) {
2479
2481
name_ = NEW_YS char [sz];
@@ -2503,8 +2505,9 @@ size_t X509_NAME::GetLength() const
2503
2505
2504
2506
2505
2507
X509::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),
2508
2511
beforeDate_ (b, bSz), afterDate_(a, aSz)
2509
2512
{}
2510
2513
@@ -2538,17 +2541,19 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
2538
2541
if (i < 0 || i >= int (sz_))
2539
2542
return 0 ;
2540
2543
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
+
2541
2550
if (entry_.data )
2542
2551
ysArrayDelete (entry_.data );
2543
- entry_.data = NEW_YS byte[sz_ ]; // max size;
2552
+ entry_.data = NEW_YS byte[cnLen_+ 1 ]; // max size;
2544
2553
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_;
2552
2557
entry_.type = 0 ;
2553
2558
2554
2559
return &entry_;
0 commit comments