This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 92c4de90c4c9bb4e13f78d74e81949eae127c479
Author: Szymon Janc <[email protected]>
AuthorDate: Thu Oct 22 00:30:12 2026 +0200

    nmxact/mtech_lora: Fix NormalizeAddr rejecting colon separated addrs
    
    NormalizeAddr stripped colons into a local copy but then stripped
    dashes from the original argument again, discarding the first
    replacement. As a result an EUI-64 given as "00:11:22:33:44:55:66:77"
    (e.g. as the LoRa session address) was rejected with "Invalid addr",
    and only plain or dash separated addresses worked.
    
    Apply the second replacement to the already processed string.
    
    Assisted-by: Claude:claude-opus-5-5
---
 nmxact/mtech_lora/mtech_lora_xport.go      | 2 +-
 nmxact/mtech_lora/mtech_lora_xport_test.go | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/nmxact/mtech_lora/mtech_lora_xport.go 
b/nmxact/mtech_lora/mtech_lora_xport.go
index 0c7f2b9..6e2b23d 100644
--- a/nmxact/mtech_lora/mtech_lora_xport.go
+++ b/nmxact/mtech_lora/mtech_lora_xport.go
@@ -114,7 +114,7 @@ func (lx *LoraXport) minMtu() int {
 
 func NormalizeAddr(addr string) (string, error) {
        a := strings.Replace(addr, ":", "", -1)
-       a = strings.Replace(addr, "-", "", -1)
+       a = strings.Replace(a, "-", "", -1)
        // XXX check that there's 8 components, 2 chars each, which are in 
[0-9,a-f]
        if len(a) != 16 {
                return "", fmt.Errorf("Invalid addr")
diff --git a/nmxact/mtech_lora/mtech_lora_xport_test.go 
b/nmxact/mtech_lora/mtech_lora_xport_test.go
index 7300e73..8fcfd2e 100644
--- a/nmxact/mtech_lora/mtech_lora_xport_test.go
+++ b/nmxact/mtech_lora/mtech_lora_xport_test.go
@@ -30,6 +30,8 @@ func TestNormalizeAddr(t *testing.T) {
        }{
                {"0011223344556677", "0011223344556677"},
                {"00-11-22-33-44-55-66-77", "0011223344556677"},
+               {"00:11:22:33:44:55:66:77", "0011223344556677"},
+               {"00:11-22:33-44:55-66:77", "0011223344556677"},
        }
 
        for _, tt := range tests {
@@ -48,6 +50,7 @@ func TestNormalizeAddr(t *testing.T) {
                "00112233445566",
                "001122334455667788",
                "00-11-22-33-44-55-66",
+               "00:11:22:33:44:55:66",
        }
        for _, s := range bad {
                if got, err := NormalizeAddr(s); err == nil {

Reply via email to