mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-01 08:03:31 +01:00
Merge branch 'bug2331' into maint-0.2.2
This commit is contained in:
commit
1e37d8678a
7
changes/bug2331
Normal file
7
changes/bug2331
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
o Minor bugfixes:
|
||||||
|
- Add assertions to check for overflow in arguments to
|
||||||
|
base32_encode and base32_decode; fix a signed-unsigned
|
||||||
|
comparison there too. These bugs are not actually reachable in
|
||||||
|
Tor, but it's good to prevent future errors too. Found by
|
||||||
|
doorss.
|
||||||
|
|
@ -2412,9 +2412,10 @@ digest256_from_base64(char *digest, const char *d64)
|
|||||||
void
|
void
|
||||||
base32_encode(char *dest, size_t destlen, const char *src, size_t srclen)
|
base32_encode(char *dest, size_t destlen, const char *src, size_t srclen)
|
||||||
{
|
{
|
||||||
unsigned int i, bit, v, u;
|
unsigned int i, v, u;
|
||||||
size_t nbits = srclen * 8;
|
size_t nbits = srclen * 8, bit;
|
||||||
|
|
||||||
|
tor_assert(srclen < SIZE_T_CEILING/8);
|
||||||
tor_assert((nbits%5) == 0); /* We need an even multiple of 5 bits. */
|
tor_assert((nbits%5) == 0); /* We need an even multiple of 5 bits. */
|
||||||
tor_assert((nbits/5)+1 <= destlen); /* We need enough space. */
|
tor_assert((nbits/5)+1 <= destlen); /* We need enough space. */
|
||||||
tor_assert(destlen < SIZE_T_CEILING);
|
tor_assert(destlen < SIZE_T_CEILING);
|
||||||
@ -2438,11 +2439,12 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
|
|||||||
{
|
{
|
||||||
/* XXXX we might want to rewrite this along the lines of base64_decode, if
|
/* XXXX we might want to rewrite this along the lines of base64_decode, if
|
||||||
* it ever shows up in the profile. */
|
* it ever shows up in the profile. */
|
||||||
unsigned int i, j, bit;
|
unsigned int i;
|
||||||
size_t nbits;
|
size_t nbits, j, bit;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
nbits = srclen * 5;
|
nbits = srclen * 5;
|
||||||
|
|
||||||
|
tor_assert(srclen < SIZE_T_CEILING / 5);
|
||||||
tor_assert((nbits%8) == 0); /* We need an even multiple of 8 bits. */
|
tor_assert((nbits%8) == 0); /* We need an even multiple of 8 bits. */
|
||||||
tor_assert((nbits/8) <= destlen); /* We need enough space. */
|
tor_assert((nbits/8) <= destlen); /* We need enough space. */
|
||||||
tor_assert(destlen < SIZE_T_CEILING);
|
tor_assert(destlen < SIZE_T_CEILING);
|
||||||
|
Loading…
Reference in New Issue
Block a user