rtrlib: Ensure data passed to users of library is sane #318
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version 0.8.0 of the library is generating this valgrind issues:
==3239843== Thread 5:
==3239843== Syscall param write(buf) points to uninitialised byte(s)
==3239843== at 0x4D308BF: __libc_write (write.c:26)
==3239843== by 0x4D308BF: write (write.c:24)
==3239843== by 0x486665A: rpki_update_cb_sync_rtr (bgp_rpki.c:758)
==3239843== by 0x54D5B9B: pfx_table_notify_clients (trie-pfx.c:64)
==3239843== by 0x54D65AD: pfx_table_add (trie-pfx.c:267)
==3239843== by 0x54DB8C6: rtr_update_pfx_table (packets.c:906)
==3239843== by 0x54DC7D8: rtr_sync_receive_and_store_pdus (packets.c:1178)
==3239843== by 0x54DD2FA: rtr_sync (packets.c:1377)
==3239843== by 0x54D94FB: rtr_fsm_start (rtr.c:155)
==3239843== by 0x4CB0AC2: start_thread (pthread_create.c:442)
==3239843== by 0x4D41A03: clone (clone.S:100)
==3239843== Address 0xa786e5c is on thread 5's stack
==3239843== in frame #2, created by pfx_table_notify_clients (trie-pfx.c:62)
Upon inspection of the code it was noticed that the
struct pfx_record
is being declared on the stack directly and then written to and passed to the callback function, in which the callback function does an immediate write of the data that was handed to it. Modify the code such that it initializes the stack data to 0's before working on it.