Commit 77f8a92
Your Name
fix(mcp): use strcpy variants in detect_changes to prevent use-after-free
detect_changes was using yyjson_mut_arr_add_str / yyjson_mut_obj_add_str
which borrow pointers. The file name came from a stack buffer reused each
fgets() iteration, and node names were freed by cbm_store_free_nodes before
serialization. This caused corrupted output with null bytes embedded in
filenames (e.g. 'CLAUDE.md\0\0\0ings.json').
Switch to yyjson_mut_arr_add_strcpy / yyjson_mut_obj_add_strcpy which copy
the strings into yyjson's internal allocator, making them safe across the
buffer reuse and free boundaries.1 parent b9f4c82 commit 77f8a92
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2602 | 2602 | | |
2603 | 2603 | | |
2604 | 2604 | | |
2605 | | - | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
2606 | 2609 | | |
2607 | 2610 | | |
2608 | 2611 | | |
| |||
2614 | 2617 | | |
2615 | 2618 | | |
2616 | 2619 | | |
2617 | | - | |
2618 | | - | |
2619 | | - | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
2620 | 2623 | | |
2621 | 2624 | | |
2622 | 2625 | | |
| |||
0 commit comments