Merge pull request #11011 from btsimonh/blefromhex

fix ble from accepting 12 char alias which does not match as a mac ad…
This commit is contained in:
Theo Arends 2021-02-17 21:40:33 +01:00 committed by GitHub
commit e335e9244b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -1015,6 +1015,18 @@ int fromHex(uint8_t *dest, const char *src, int maxlen){
t[0] = src[i*2];
t[1] = src[i*2 + 1];
t[2] = 0;
t[0] |= 0x20;
t[1] |= 0x20;
if (isalpha(t[0])){
if (t[0] < 'a' || t[0] > 'f'){
return 0;
}
}
if (isalpha(t[1])){
if (t[1] < 'a' || t[1] > 'f'){
return 0;
}
}
int byte = strtol(t, NULL, 16);
*dest++ = byte;