]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5101] Avoid uint16_t >> 16 (CID 1398333)
authorFrancis Dupont <fdupont@isc.org>
Wed, 4 Jan 2017 14:35:43 +0000 (15:35 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 4 Jan 2017 14:35:43 +0000 (15:35 +0100)
src/lib/dhcp/option_data_types.cc

index 55a0145c67d251d5f87088a1d07bc181d03f0501..7ab72b3a9fa1994efc0be7ec31b47e1627db2c07 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -420,7 +420,12 @@ OptionDataTypeUtil::readPsid(const std::vector<uint8_t>& buf) {
 
     // All is good, so we can convert the PSID value read from the buffer to
     // the port set number.
-    psid = psid >> (sizeof(psid) * 8 - psid_len);
+    if (psid_len == sizeof(psid) * 8) {
+        // Shift by 16 always gives zero (CID 1398333)
+        psid = 0;
+    } else {
+        psid = psid >> (sizeof(psid) * 8 - psid_len);
+    }
     return (std::make_pair(PSIDLen(psid_len), PSID(psid)));
 }