FS#1321 - UCI potential invalid memory access when updating existing section #5783
There is a potential memory leak when updating existing section in [[
Return pointer from realloc may not be the same as ptr->s. Due to realloc mechanism, pointers value from ptr->s->options are copied to the ptr->last. However, those pointers (ptr->last->s->options) are pointing back to the ptr->s which has been freed.
Below are steps to reproduce.
Given a config file like that
Given test codes like that
Runs like that
Here is the output of valgrind before the hotfix below
Please take a look the attachment. It includes my hot fix for this issue and corresponding demo codes as illustrated above.
I am not sure how to "update" the "uci_options" associated to the "uci_section". So, I simply omit and replace the realloc part.
Tested by valgrind again
The text was updated successfully, but these errors were encountered:
Sorry for replying late.
It seems like there is no github repository for project UCI. Does it means that I must submit the patch via patchwork? As I am not familiar with the mailing way, I would prefer to submit a PR via Github. What should I do?
Thanks for your time