summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2024-02-06 21:38:23 +0100
committerThomas Markwalder <tmark@isc.org>2024-02-07 14:58:47 +0100
commitef1f878f5272d2f9c9d27b2dd592055e330ac887 (patch)
tree6c80cbeda40602f4934d16033c522c38eb2e2098 /src
parent[#3209] Addressed review comments (diff)
downloadkea-ef1f878f5272d2f9c9d27b2dd592055e330ac887.tar.xz
kea-ef1f878f5272d2f9c9d27b2dd592055e330ac887.zip
[#3209] Further review comments
modified: encode/encode.cc
Diffstat (limited to 'src')
-rw-r--r--src/lib/util/encode/encode.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/util/encode/encode.cc b/src/lib/util/encode/encode.cc
index af63fc0037..c318849f9f 100644
--- a/src/lib/util/encode/encode.cc
+++ b/src/lib/util/encode/encode.cc
@@ -106,7 +106,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
} else {
// No, the index is complete, lookup its digit and add it to the
// output. Start over for the next index.
- encoded_output.push_back(digit_set_[digit_idx]);
+ encoded_output.push_back(bitsToDigit(digit_idx));
digit_idx = 0;
cnt = 0;
}
@@ -149,7 +149,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
void
BaseNEncoder::decode(const std::string& encoded_str, std::vector<uint8_t>& output) {
- // Mechanics are the essentially the same as encode(). We iterate over the encoded
+ // Mechanics are essentially the same as encode(). We iterate over the encoded
// string's digits, discarding whitespaces. We lookup the digit's binary value
// in the lookup table, keeping only binary value's right-most, bits_per_digit bits.
// The remaining bits are then shifted out from the left of binary value into the
@@ -250,10 +250,10 @@ BaseNEncoder::decode(const std::string& encoded_str, std::vector<uint8_t>& outpu
// The number of bits for the '==...' part is padchars * BitsPerChunk.
// So the total number of pad bits is the smallest multiple of 8
// that is >= padchars * BitsPerChunk.
- // (Below, note the common idiom of the bitwise AND with ~7. It clears the
+ // (Below, note the common idiom of the bitwise AND with ~0x7. It clears the
// lowest three bits, so has the effect of rounding the result down to the
// nearest multiple of 8)
- const size_t padbits = ((pad_cnt * bits_per_digit_) + 0x07) & ~0x07;
+ const size_t padbits = ((pad_cnt * bits_per_digit_) + 7) & ~0x7;
if (padbits > bits_per_digit_ * (pad_cnt + 1)) {
isc_throw(isc::BadValue, "Invalid padding for "
<< algorithm_ << ": " << encoded_str);