This commit is contained in:
Adam Ierymenko 2019-08-07 11:20:12 -05:00
parent 455cd5551b
commit 54a1bbd016
No known key found for this signature in database
GPG key ID: 1657198823E52A61
14 changed files with 94 additions and 268 deletions

View file

@ -213,9 +213,11 @@ int Utils::b32d(const char *encoded, uint8_t *result, int bufSize)
int Utils::b32e(const uint8_t *data,int length,char *result,int bufSize)
{
if (length < 0 || length > (1 << 28))
if (length < 0 || length > (1 << 28)) {
result[0] = (char)0;
return -1;
int count = 0;
}
int count = 0;
if (length > 0) {
int buffer = data[0];
int next = 1;
@ -237,9 +239,12 @@ int Utils::b32e(const uint8_t *data,int length,char *result,int bufSize)
result[count++] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"[index];
}
}
if (count < bufSize)
result[count] = (char)0;
return count;
if (count < bufSize) {
result[count] = (char)0;
return count;
}
result[0] = (char)0;
return -1;
}
} // namespace ZeroTier