-
Notifications
You must be signed in to change notification settings - Fork 20
FIXING main vul #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
FIXING main vul #26
Conversation
| 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function presenting vulns
| for (i = 0; i < vector->count; i++) { | ||
| iterator = pico_dns_sd_kv_vector_get(vector, i); | ||
|
|
||
| if (!iterator || iterator->key){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Diebbo Did you mean?
| 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) { |
There was a problem hiding this comment.
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?
nameis not a NULL pointer (with your previously added check) solabelwill not be a NULL pointer as well (at least, at the beginning of the loop)- Macro
dns_name_foreach_label_safeensures*label <= 63so, 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
| 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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
No description provided.