Commit d5fbef09 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5340] Fixed invalid use of Pkt4::setFile and Pkt4::setSname functions.

parent 0d05123d
...@@ -401,14 +401,16 @@ Dhcpv4Exchange::setReservedMessageFields() { ...@@ -401,14 +401,16 @@ Dhcpv4Exchange::setReservedMessageFields() {
resp_->setSiaddr(host->getNextServer()); resp_->setSiaddr(host->getNextServer());
} }
if (!host->getServerHostname().empty()) { std::string sname = host->getServerHostname();
resp_->setSname(reinterpret_cast< if (!sname.empty()) {
const uint8_t*>(host->getServerHostname().c_str())); resp_->setSname(reinterpret_cast<const uint8_t*>(sname.c_str()),
sname.size());
} }
if (!host->getBootFileName().empty()) { std::string bootfile = host->getBootFileName();
resp_->setFile(reinterpret_cast< if (!bootfile.empty()) {
const uint8_t*>(host->getBootFileName().c_str())); resp_->setFile(reinterpret_cast<const uint8_t*>(bootfile.c_str()),
bootfile.size());
} }
} }
} }
......
...@@ -269,7 +269,7 @@ public: ...@@ -269,7 +269,7 @@ public:
/// ///
/// @param sname value to be set /// @param sname value to be set
/// @param sname_len length of the sname buffer (up to MAX_SNAME_LEN) /// @param sname_len length of the sname buffer (up to MAX_SNAME_LEN)
void setSname(const uint8_t* sname, size_t sname_len = MAX_SNAME_LEN); void setSname(const uint8_t* sname, size_t sname_len);
/// @brief Returns file field /// @brief Returns file field
/// ///
...@@ -285,7 +285,7 @@ public: ...@@ -285,7 +285,7 @@ public:
/// @param file value to be set /// @param file value to be set
/// @param file_len length of the file buffer (up to MAX_FILE_LEN) /// @param file_len length of the file buffer (up to MAX_FILE_LEN)
void void
setFile(const uint8_t* file, size_t file_len = MAX_FILE_LEN); setFile(const uint8_t* file, size_t file_len);
/// @brief Sets hardware address. /// @brief Sets hardware address.
/// ///
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment