]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3546] (hopefully) last changes after review:
authorTomek Mrugalski <tomasz@isc.org>
Tue, 7 Oct 2014 14:17:42 +0000 (16:17 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 7 Oct 2014 14:17:42 +0000 (16:17 +0200)
 - clarified that returned offset refers to last successfully parsed option
 - unpackOptions6() now returns proper offset if vendor-option is truncated

src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h

index 9b100a9c3965706937849aa0fc25436758a03e45..93961b9b9f2173222946b2aa2e59e4a1dc5dfc09 100644 (file)
@@ -260,8 +260,9 @@ size_t LibDHCP::unpackOptions6(const OptionBuffer& buf,
         if (opt_type == D6O_VENDOR_OPTS) {
             if (offset + 4 > length) {
                 // Truncated vendor-option. There is expected at least 4 bytes
-                // long enterprise-id field
-                return (offset);
+                // long enterprise-id field. Let's roll back option code + option
+                // length (4 bytes) and return.
+                return (offset - 4);
             }
 
             // Parse this as vendor option
index 230ba9480cd0ea209cb634a0960364fc1ee5a3a9..642d2ab6d286dd86379db864f118b3843c4801df 100644 (file)
@@ -123,6 +123,7 @@ public:
     /// of to be used to parse options in the packets.
     /// @param options Reference to option container. Options will be
     ///        put here.
+    /// @return offset to the first byte after the last successfully parsed option
     static size_t unpackOptions4(const OptionBuffer& buf,
                                  const std::string& option_space,
                                  isc::dhcp::OptionCollection& options);
@@ -147,7 +148,7 @@ public:
     ///        offset to beginning of relay_msg option will be stored in it.
     /// @param relay_msg_len reference to a size_t structure. If specified,
     ///        length of the relay_msg option will be stored in it.
-    /// @return offset to the first byte after last parsed option
+    /// @return offset to the first byte after the last successfully parsed option
     static size_t unpackOptions6(const OptionBuffer& buf,
                                  const std::string& option_space,
                                  isc::dhcp::OptionCollection& options,
@@ -192,6 +193,7 @@ public:
     /// @param buf Buffer to be parsed.
     /// @param options Reference to option container. Options will be
     ///        put here.
+    /// @return offset to the first byte after the last successfully parsed option
     static size_t unpackVendorOptions6(const uint32_t vendor_id,
                                        const OptionBuffer& buf,
                                        isc::dhcp::OptionCollection& options);
@@ -206,6 +208,7 @@ public:
     /// @param buf Buffer to be parsed.
     /// @param options Reference to option container. Options will be
     ///        put here.
+    /// @return offset to the first byte after the last successfully parsed option
     static size_t unpackVendorOptions4(const uint32_t vendor_id, const OptionBuffer& buf,
                                        isc::dhcp::OptionCollection& options);