Browse Source

[4306] Fixed CID 1202663 and 1202665

Francis Dupont 9 years ago
parent
commit
898da67758
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/lib/dhcp/pkt4.cc

+ 6 - 2
src/lib/dhcp/pkt4.cc

@@ -478,7 +478,9 @@ Pkt4::setSname(const uint8_t* sname, size_t snameLen /*= MAX_SNAME_LEN*/) {
     }
 
     std::copy(sname, (sname + snameLen), sname_);
-    std::fill((sname_ + snameLen), (sname_ + MAX_SNAME_LEN), 0);
+    if (snameLen < MAX_SNAME_LEN) {
+        std::fill((sname_ + snameLen), (sname_ + MAX_SNAME_LEN), 0);
+    }
 
     // No need to store snameLen as any empty space is filled with 0s
 }
@@ -494,7 +496,9 @@ Pkt4::setFile(const uint8_t* file, size_t fileLen /*= MAX_FILE_LEN*/) {
     }
 
     std::copy(file, (file + fileLen), file_);
-    std::fill((file_ + fileLen), (file_ + MAX_FILE_LEN), 0);
+    if (fileLen < MAX_FILE_LEN) {
+        std::fill((file_ + fileLen), (file_ + MAX_FILE_LEN), 0);
+    }
 
     // No need to store fileLen as any empty space is filled with 0s
 }