mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Merge remote-tracking branch 'public/bug21894_029' into maint-0.3.0
This commit is contained in:
commit
f1613b53c5
2 changed files with 9 additions and 3 deletions
5
changes/bug21894_029
Normal file
5
changes/bug21894_029
Normal file
|
@ -0,0 +1,5 @@
|
|||
o Minor bugfixes (crash prevention):
|
||||
- Fix an (currently untriggerable, but potentially dangerous) crash
|
||||
bug when base32-encoding inputs whose sizes are not a multiple of
|
||||
5. Fixes bug 21894; bugfix on 0.2.9.1-alpha.
|
||||
|
|
@ -51,9 +51,10 @@ base32_encode(char *dest, size_t destlen, const char *src, size_t srclen)
|
|||
|
||||
for (i=0,bit=0; bit < nbits; ++i, bit+=5) {
|
||||
/* set v to the 16-bit value starting at src[bits/8], 0-padded. */
|
||||
v = ((uint8_t)src[bit/8]) << 8;
|
||||
if (bit+5<nbits)
|
||||
v += (uint8_t)src[(bit/8)+1];
|
||||
size_t idx = bit / 8;
|
||||
v = ((uint8_t)src[idx]) << 8;
|
||||
if (idx+1 < srclen)
|
||||
v += (uint8_t)src[idx+1];
|
||||
/* set u to the 5-bit value at the bit'th bit of buf. */
|
||||
u = (v >> (11-(bit%8))) & 0x1F;
|
||||
dest[i] = BASE32_CHARS[u];
|
||||
|
|
Loading…
Add table
Reference in a new issue