File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -351,11 +351,26 @@ Binary Session::MyDestination() const
351
351
static constexpr size_t CERT_LEN_POS = 385 ;
352
352
353
353
uint16_t cert_len;
354
+
355
+ if (m_private_key.size () < CERT_LEN_POS + sizeof (cert_len)) {
356
+ throw std::runtime_error (strprintf (" The private key is too short (%d < %d)" ,
357
+ m_private_key.size (),
358
+ CERT_LEN_POS + sizeof (cert_len)));
359
+ }
360
+
354
361
memcpy (&cert_len, &m_private_key.at (CERT_LEN_POS), sizeof (cert_len));
355
362
cert_len = be16toh (cert_len);
356
363
357
364
const size_t dest_len = DEST_LEN_BASE + cert_len;
358
365
366
+ if (dest_len > m_private_key.size ()) {
367
+ throw std::runtime_error (strprintf (" Certificate length (%d) designates that the private key should "
368
+ " be %d bytes, but it is only %d bytes" ,
369
+ cert_len,
370
+ dest_len,
371
+ m_private_key.size ()));
372
+ }
373
+
359
374
return Binary{m_private_key.begin (), m_private_key.begin () + dest_len};
360
375
}
361
376
You can’t perform that action at this time.
0 commit comments