Skip to content

Conversation

@Diebbo
Copy link
Collaborator

@Diebbo Diebbo commented Dec 20, 2024

No description provided.

@Diebbo
Copy link
Collaborator Author

Diebbo commented Dec 20, 2024

memcpy(&decompressed_name[decompressed_index], label, label_size);
decompressed_index = (uint16_t)(decompressed_index+label_size);
}
char *pico_dns_decompress_name(char *name, pico_dns_packet *packet) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

function presenting vulns

@Diebbo Diebbo marked this pull request as ready for review February 24, 2025 11:06
@danielinux danielinux self-assigned this Mar 4, 2025
@danielinux danielinux mentioned this pull request Nov 11, 2025
for (i = 0; i < vector->count; i++) {
iterator = pico_dns_sd_kv_vector_get(vector, i);

if (!iterator || iterator->key){
Copy link
Collaborator

@scribam scribam Nov 15, 2025

Choose a reason for hiding this comment

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

@Diebbo Did you mean?

Suggested change
if (!iterator || iterator->key){
if (!iterator || !iterator->key){

* Only one pointer is allowed in DNS compression, the pointer is always the
* last according to the RFC */
dns_name_foreach_label_safe(label, name, next, PICO_DNS_NAMEBUF_SIZE) {
if (!label || (*label & 0xFF) >= PICO_DNS_NAMEBUF_SIZE) {
Copy link
Collaborator

@scribam scribam Nov 15, 2025

Choose a reason for hiding this comment

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

@Diebbo Are these checks necessary?

  • name is not a NULL pointer (with your previously added check) so label will not be a NULL pointer as well (at least, at the beginning of the loop)
  • Macro dns_name_foreach_label_safe ensures *label <= 63 so, to me, (*label & 0xFF) >= PICO_DNS_NAMEBUF_SIZE) will be always false

Let me know if I missed something or if you have an example that makes these checks relevant

This was referenced Nov 29, 2025
decompressed_index = (uint16_t)(decompressed_index+label_size);
}
char *pico_dns_decompress_name(char *name, pico_dns_packet *packet) {
uint16_t packet_len = sizeof(pico_dns_packet);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is wrong as it does not represent the whole size of the packet but a fixed size corresponding to the size of the dns header (12).

ptr = (uint16_t)(ptr | (uint16_t)*(label + 1));

/* Check if the pointer is within the packet */
if (ptr >= packet_len) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unit test "tc_mdns_handle_data_as_questions" fails here because there is compression pointer with an offset >= 12

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