diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2017-03-06 11:51:10 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2017-03-06 18:54:09 +0100 |
commit | cfdccc93f5e102bdda6db89d1f4a033166c0365c (patch) | |
tree | e7b3202b100aff796404921795a23a57ae75ae76 /src/libstrongswan/utils/chunk.c | |
parent | 2d41e1c51cf88cefe216aed1172a96c4816044e3 (diff) | |
download | strongswan-cfdccc93f5e102bdda6db89d1f4a033166c0365c.tar.bz2 strongswan-cfdccc93f5e102bdda6db89d1f4a033166c0365c.tar.xz |
utils: chunk_from_hex() skips optional 0x prefix
Diffstat (limited to 'src/libstrongswan/utils/chunk.c')
-rw-r--r-- | src/libstrongswan/utils/chunk.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstrongswan/utils/chunk.c b/src/libstrongswan/utils/chunk.c index 2f824a259..0c50ab788 100644 --- a/src/libstrongswan/utils/chunk.c +++ b/src/libstrongswan/utils/chunk.c @@ -504,7 +504,13 @@ chunk_t chunk_from_hex(chunk_t hex, char *buf) u_char *ptr; bool odd = FALSE; - /* subtract the number of optional ':' separation characters */ + /* skip an optional 0x prefix */ + if (hex.len > 1 && hex.ptr[1] == 'x' && hex.ptr[0] == '0') + { + hex = chunk_skip(hex, 2); + } + + /* subtract the number of optional ':' separation characters */ len = hex.len; ptr = hex.ptr; for (i = 0; i < hex.len; i++) |