diff options
author | michael-methner <mmethner@de.adit-jv.com> | 2022-10-11 04:53:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 09:53:12 +0700 |
commit | 154d225b934de70387533f3dfaf5d449a580c28b (patch) | |
tree | f2601b9fe713bb01f047edf67328b9fd1dd8dead /include | |
parent | e961a8f7c0f655a4379c8c6bcf745f89604c453f (diff) | |
download | DLT-daemon-154d225b934de70387533f3dfaf5d449a580c28b.tar.gz |
Avoid memory corruption behind buffer wp in function dlt_getloginfo_conv_ascii_to_id (#411)
* Avoid memory corruption behind buffer wp in function dlt_getloginfo_conv_ascii_to_id
- Introduced new function dlt_getloginfo_conv_ascii_to_string for '\0' terminated strings
- Avoid printing garbage characters in dlt-control after APID and CTID (which are not null terminated anymore)
- Added unit test for dlt_client_parse_get_log_info_resp_text and dlt_getloginfo_conv_ascii_to_string
- Use dlt_getloginfo_conv_ascii_to_string to get '\0' terminated for app_description and context_description
Signed-off-by: Michael Methner <mmethner@de.adit-jv.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/dlt/dlt_common.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 100a481..ead124f 100644 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -1631,15 +1631,28 @@ int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count); */ int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count); + +/** + * Convert get log info from ASCII to string (with '\0' termination) + * + * @param rp char + * @param rp_count int + * @param wp char Array needs to be 1 byte larger than len to store '\0' + * @param len int + */ +void dlt_getloginfo_conv_ascii_to_string(char *rp, int *rp_count, char *wp, int len); + + /** - * Convert get log info from ASCII to ID + * Convert get log info from ASCII to ID (without '\0' termination) * * @param rp char * @param rp_count int * @param wp char * @param len int + * @return position of last read character in wp */ -void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len); +int dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len); /** * Convert from hex ASCII to binary |