Parcourir la source

[master] Merged trac5101 (Coverity fixes)

Francis Dupont il y a 8 ans
Parent
commit
7c975ed410

+ 2 - 2
src/bin/dhcp4/parser_context.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-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
@@ -16,7 +16,7 @@ namespace isc {
 namespace dhcp {
 
 Parser4Context::Parser4Context()
-  : trace_scanning_(false), trace_parsing_(false)
+  : ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false)
 {
 }
 

+ 2 - 2
src/bin/dhcp6/parser_context.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-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
@@ -16,7 +16,7 @@ namespace isc {
 namespace dhcp {
 
 Parser6Context::Parser6Context()
-  : trace_scanning_(false), trace_parsing_(false)
+  : ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false)
 {
 }
 

+ 8 - 6
src/lib/cc/data.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-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
@@ -798,11 +798,13 @@ StringElement::toJSON(std::ostream& ss) const {
             break;
         default:
             if ((c >= 0) && (c < 0x20)) {
-                ss << "\\u"
-                   << hex
-                   << setw(4)
-                   << setfill('0')
-                   << (static_cast<unsigned>(c) & 0xff);
+                std::ostringstream esc;
+                esc << "\\u"
+                    << hex
+                    << setw(4)
+                    << setfill('0')
+                    << (static_cast<unsigned>(c) & 0xff);
+                ss << esc.str();
             } else {
                 ss << c;
             }

+ 7 - 2
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<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)));
 }