]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2764] detect intermediate padding explicitly.
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 6 Mar 2013 04:27:24 +0000 (20:27 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 6 Mar 2013 04:27:24 +0000 (20:27 -0800)
we previously relied on boost rejecting the padding chracter and throwing
an exception; since Boost 1.53 paddding characters are considered valid
and conerted to all-0 bits, so we now have to do it ourselves.  The detection
logic doesn't rely on the new behavior of Boost, so it should be backward
compatible.

src/lib/util/encode/base_n.cc

index 3ea4486190350e7eb40b2aec1a8819584b627c85..acf3d3e4a5f27e2622e151213df363f363d773d5 100644 (file)
@@ -203,8 +203,16 @@ public:
             // we can catch and reject this type of invalid input.
             isc_throw(BadValue, "Unexpected end of input in BASE decoder");
         }
-        if (in_pad_) {
-            return (base_zero_code_);
+        if (*base_ == BASE_PADDING_CHAR) {
+            // Padding can only happen at the end of the input string.  We can
+            // detect any violation of this by checking in_pad_, which is
+            // true iff we are on or after the first valid sequence of padding
+            // characters.
+            if (in_pad_) {
+                return (base_zero_code_);
+            } else {
+                isc_throw(BadValue, "Intermediate padding found");
+            }
         } else {
             return (*base_);
         }