Skip to content

dtls_debug.c: fix minor bug with zero termination.#121

Merged
obgm merged 1 commit intoeclipse-tinydtls:developfrom
bosch-io:fix_dsrv_print_addr
Feb 3, 2022
Merged

dtls_debug.c: fix minor bug with zero termination.#121
obgm merged 1 commit intoeclipse-tinydtls:developfrom
bosch-io:fix_dsrv_print_addr

Conversation

@boaks
Copy link
Copy Markdown
Contributor

@boaks boaks commented Jan 7, 2022

Providing a too small buffer may result in missing the zero termination.
This fix prevents that, even if currently no too small buffers are
used.

Signed-off-by: Achim Kraus achim.kraus@bosch.io

@boaks boaks force-pushed the fix_dsrv_print_addr branch from 3984f7c to 65efd6c Compare January 7, 2022 10:52
dtls_debug.c Outdated
default:
memcpy(buf, "(unknown address type)", min(22, len));
return min(22, len);
// include terminating \000
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.

Please use the /* ... */ comment syntax.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will do. (Sorry for that, I work on too much stuff in parallel with all different rules. Please keep on requesting to comply to your source format rules.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@boaks boaks force-pushed the fix_dsrv_print_addr branch 4 times, most recently from 7518cf8 to fc73961 Compare January 18, 2022 16:26
@boaks
Copy link
Copy Markdown
Contributor Author

boaks commented Jan 18, 2022

Now with "assert".

Providing a too small buffer may result in missing the zero termination.
This adds an assert to ensure, that the buffer is large enough.

Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
@boaks boaks force-pushed the fix_dsrv_print_addr branch from fc73961 to d7b94c0 Compare January 21, 2022 08:15
@boaks
Copy link
Copy Markdown
Contributor Author

boaks commented Jan 21, 2022

Now, with two locals.

@obgm
Copy link
Copy Markdown
Contributor

obgm commented Feb 3, 2022

Thanks for doing the changes!

@obgm obgm merged commit 5f7d89c into eclipse-tinydtls:develop Feb 3, 2022
@boaks boaks deleted the fix_dsrv_print_addr branch May 23, 2022 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants