Skip to content

feat(common): add wpa_hexdump_ascii function - #440

Merged
aloisklink merged 2 commits into
mainfrom
feat/add-wpa_hexdump_ascii
Feb 24, 2023
Merged

feat(common): add wpa_hexdump_ascii function#440
aloisklink merged 2 commits into
mainfrom
feat/add-wpa_hexdump_ascii

Conversation

@aloisklink

Copy link
Copy Markdown
Contributor

Add wpa_hexdump_ascii to match the API of wpa_hexdump_ascii() from hostap.

Please note that this function acts differently from the hostap version of the function:

  • It only prints the first 16 bytes.
  • It prints all bytes as hex, never as ASCII.

Adapted from commit dff384c.

My changes compared to dff384c:

  • Added documentation
  • Use __maybe_unused (from 5a3a8bf) to mark the unused level param.
  • I've changed the number of bytes in the buffer to 33 instead of 32. This is because we need a byte for the NUL-terminator too (see 24fe4cb for more information), otherwise printf_hex causes a mid-byte truncation issue.

aloisklink and others added 2 commits February 21, 2023 16:50
Add `wpa_hexdump_ascii` to match the API of `wpa_hexdump_ascii()`
from hostap.

Please note that this function acts differently from the hostap
version of the function:
  - It only prints the first 15 bytes.
  - It prints all bytes as hex, never as ASCII.

Co-authored-by: Alexandru Mereacre <mereacre@gmail.com>
wpa_hexdump_ascii() currently uses a 32-byte output buffer when calling
`printf_hex()`. However, `printf_hex()` must have a odd-number sized
buffer to avoid truncating the hexstring in the middle of a byte, as
the output buffer string must be NUL-terminated.

Changing the hex buffer size to 33-bytes prevents a mid-byte
truncation.
@aloisklink aloisklink added the enhancement New feature or request label Feb 21, 2023
@aloisklink aloisklink added this to the RADIUS ERP Server milestone Feb 21, 2023
@codecov

codecov Bot commented Feb 21, 2023

Copy link
Copy Markdown

Codecov Report

Merging #440 (eccae1e) into main (595fe95) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #440      +/-   ##
==========================================
+ Coverage   53.08%   53.09%   +0.01%     
==========================================
  Files         144      144              
  Lines       19870    19876       +6     
==========================================
+ Hits        10547    10553       +6     
  Misses       9323     9323              
Impacted Files Coverage Δ
src/radius/common.h 42.59% <ø> (ø)
src/utils/os.h 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@aloisklink aloisklink mentioned this pull request Feb 21, 2023

@mereacre mereacre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.

@aloisklink
aloisklink added this pull request to the merge queue Feb 24, 2023
Merged via the queue into main with commit 3b54049 Feb 24, 2023
@aloisklink
aloisklink deleted the feat/add-wpa_hexdump_ascii branch February 24, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants