diff options
author | Simon Rettberg | 2024-04-12 14:00:15 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-04-12 14:00:15 +0200 |
commit | 98dc341428e247141f120d05fac48c4e144a4c0f (patch) | |
tree | 3ebacb37927e338383ac64c2e20eb0b2f820cb85 /src/core/base16.c | |
parent | Merge branch 'master' into openslx (diff) | |
parent | Merge branch 'ipxe:master' into aqc1xx (diff) | |
download | ipxe-98dc341428e247141f120d05fac48c4e144a4c0f.tar.gz ipxe-98dc341428e247141f120d05fac48c4e144a4c0f.tar.xz ipxe-98dc341428e247141f120d05fac48c4e144a4c0f.zip |
Merge branch 'aqc1xx' into openslx
Diffstat (limited to 'src/core/base16.c')
-rw-r--r-- | src/core/base16.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/base16.c b/src/core/base16.c index f9e0f336..47e35f41 100644 --- a/src/core/base16.c +++ b/src/core/base16.c @@ -78,12 +78,23 @@ int hex_decode ( char separator, const char *encoded, void *data, size_t len ) { unsigned int count = 0; unsigned int sixteens; unsigned int units; + int optional; + /* Strip out optionality flag from separator character */ + optional = ( separator & HEX_DECODE_OPTIONAL ); + separator &= ~HEX_DECODE_OPTIONAL; + + /* Decode string */ while ( *encoded ) { /* Check separator, if applicable */ - if ( count && separator && ( ( *(encoded++) != separator ) ) ) - return -EINVAL; + if ( count && separator ) { + if ( *encoded == separator ) { + encoded++; + } else if ( ! optional ) { + return -EINVAL; + } + } /* Extract digits. Note that either digit may be NUL, * which would be interpreted as an invalid value by |