diff options
author | Jari Sundell <sundell.software@gmail.com> | 2011-12-06 14:09:48 +0900 |
---|---|---|
committer | Jari Sundell <sundell.software@gmail.com> | 2011-12-06 14:09:48 +0900 |
commit | 97b84c61a440c468ebe510dcc83165b149d12ac9 (patch) | |
tree | 87bf4bff41a8ccf4cf1ed7e46ada2a01e237d4a4 | |
parent | 37cf9201f2e34f89f228d952768f10461911d314 (diff) | |
download | net-dhcp-ruby-97b84c61a440c468ebe510dcc83165b149d12ac9.tar.gz |
Handle chaddr arrays with fewer or more elements than the required 16 bytes.
-rw-r--r-- | lib/net/dhcp/core.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/net/dhcp/core.rb b/lib/net/dhcp/core.rb index 9a97f51..ab8d38a 100644 --- a/lib/net/dhcp/core.rb +++ b/lib/net/dhcp/core.rb @@ -157,8 +157,11 @@ module DHCP self.giaddr ].pack('C4Nn2N4') - out << self.chaddr.pack('C16') - + if self.chaddr.size >= 16 + out << self.chaddr.pack('C16') + else + out << (self.chaddr + [0x00]*(19-self.chaddr.size)).pack('C16') + end # sname and file out << ([0x00]*192).pack('C192') |