|
@@ -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
|
|
|
}
|