Skip to content

Fix oob reads in dtls check tls extension - #276

Merged
boaks merged 5 commits into
eclipse-tinydtls:mainfrom
boaks:fix_oob_reads_in_dtls_check_tls_extension
Oct 2, 2026
Merged

boaks merged 5 commits into
eclipse-tinydtls:mainfrom
boaks:fix_oob_reads_in_dtls_check_tls_extension

Conversation

@boaks

@boaks boaks commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@obgm obgm 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.

In general, these changes address the OOB read issue. There are two pitfalls regarding the break condition for the for loops that decrease i by 2 due to the now unsigned data type.

Coding style: This PR mixes uint16_t (the standardized type from stdint.h and uint16 (the local typedef for compatibility with platforms that do not have the standard C library). For consistency, I suggest using uint16 throughout the code.

Comment thread dtls.c Resolved
Comment thread dtls.c Resolved
boaks added 4 commits October 1, 2026 07:34
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
@boaks

boaks commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

I suggest using uint16 throughout the code.

typedef unsigned char uint16[2];

   uint16 i = 0;
   i++;

if we use the uint16, arithmetic will fail. Those types are only usable for sizeof().

I will add the checks for odd lengths.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
@boaks
boaks force-pushed the fix_oob_reads_in_dtls_check_tls_extension branch from 720d6d1 to a5bc22f Compare October 1, 2026 05:51
@obgm

obgm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

typedef unsigned char uint16[2];

if we use the uint16, arithmetic will fail. Those types are only usable for sizeof().

Hm, a quick check shows 2 as a result for sizeof(i) as well as sizeof(uint16) with this typedef.

@boaks

boaks commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

I suggest using uint16 throughout the code.

if uint16 is used for i, the compiler reports errors. There I use uint16_t.

@mrdeep1

mrdeep1 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Yes, uint16 is an array of 2 bytes and so cannot be a single number.

@obgm

obgm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Very valid point.

@boaks
boaks merged commit b8f6213 into eclipse-tinydtls:main Oct 2, 2026
6 checks passed
@boaks
boaks deleted the fix_oob_reads_in_dtls_check_tls_extension branch October 4, 2026 08:05
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