erlang-uuid
erlang-uuid copied to clipboard
Fixes for hardware addresses that are zero or not six octets
Howdy, I've got two patches stored in my local git repository.
One corrects the directory hierarchy to move the include file into an include directory.
The other one fixes the case where a system has devices with hardware addresses that are zero or consist of other than six octets. Linux sit devices, for example, default to four bytes of zeros.
I can't create a text patch for the directory layout change, but the byte problem is included below.
If you want the direct (teste) push of both I need permissions.
src/uuid.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/uuid.erl b/src/uuid.erl
index 38a27c2..ecb7a66 100644
--- a/src/uuid.erl
+++ b/src/uuid.erl
@@ -318,8 +318,12 @@ hwaddr_find([{"lo", _IfConfig}|Rest]) ->
hwaddr_find(Rest);
hwaddr_find([{_IfName, IfConfig}|Rest]) ->
case lists:keyfind(hwaddr, 1, IfConfig) of
- {hwaddr, HwAddr} ->
+ {hwaddr, [0,0,0,0,0,0] = _HwAddr} ->
+ hwaddr_find(Rest);
+ {hwaddr, HwAddr} when length(HwAddr) == 6 ->
list_to_binary(HwAddr);
+ {hwaddr, _HwAddr} ->
+ hwaddr_find(Rest);
false ->
hwaddr_find(Rest)
end;
--
2.22.0
Thanks!
Can you push your repository to github and open a pull request?