From: Francis Dupont Date: Wed, 4 Jan 2017 14:35:43 +0000 (+0100) Subject: [5101] Avoid uint16_t >> 16 (CID 1398333) X-Git-Tag: fdflex_base^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=1726052c902aed4e3b5c193c1005731fa54c1e7e;p=thirdparty%2Fkea.git [5101] Avoid uint16_t >> 16 (CID 1398333) --- diff --git a/src/lib/dhcp/option_data_types.cc b/src/lib/dhcp/option_data_types.cc index 55a0145c67..7ab72b3a9f 100644 --- a/src/lib/dhcp/option_data_types.cc +++ b/src/lib/dhcp/option_data_types.cc @@ -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& 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))); }