diff options
author | Leah Rowe <leah@libreboot.org> | 2025-05-05 07:22:44 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-05-05 07:22:44 +0100 |
commit | a2f390af743f18346de69d7008bcf09a2fd71209 (patch) | |
tree | 9b2dd13b8d594ede4ec12ae9f8b372db4ea6135c /util/nvmutil/nvmutil.c | |
parent | 647e2f3b40d318031445b5874f18cab187ad55ee (diff) | |
parent | d35cbcb3e4949aa6a5747708f54925b23d2fc4b0 (diff) |
Merge branch 'master' into 25.04_branch
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r-- | util/nvmutil/nvmutil.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 12aabe4d..05459bb7 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -40,7 +40,7 @@ size_t partsize, gbe[2]; uint8_t nvmPartChanged[2] = {0, 0}, do_read[2] = {1, 1}; int flags, rfd, fd, part; -const char *strMac = NULL, *strRMac = "??:??:??:??:??:??", *filename = NULL; +const char *strMac = NULL, *strRMac = "xx:xx:xx:xx:xx:xx", *filename = NULL; typedef struct op { char *str; @@ -278,8 +278,11 @@ parseMacString(const char *strMac, uint16_t *mac) err(errno = EINVAL, "Invalid character '%c'", strMac[i + nib]); + /* If random, ensure that local/unicast bits are set */ if ((byte == 0) && (nib == 1)) - if (strMac[i + nib] == '?') /* ?=random */ + if ((strMac[i + nib] == '?') || + (strMac[i + nib] == 'x') || + (strMac[i + nib] == 'X')) /* random */ h = (h & 0xE) | 2; /* local, unicast */ mac[byte >> 1] |= ((uint16_t ) h) @@ -302,7 +305,10 @@ hextonum(char ch) return ch - 'A' + 10; else if ((ch >= 'a') && (ch <= 'f')) return ch - 'a' + 10; - return (ch == '?') ? rhex() : 16; + else if ((ch == '?') || (ch == 'x') || (ch == 'X')) + return rhex(); /* random hex value */ + else + return 16; /* error: invalid character */ } uint8_t |