ripd: fix data-handling in several places - #21215
Merged
Merged
Conversation
added 2 commits
March 17, 2026 15:18
route_node->info is a list, not a single object; use it correctly, and avoid NULL-deref potential. Signed-off-by: Mark Stapp <mjs@cisco.com>
Ensure the simple-auth string is in a NULL-terminated buffer before printing it with '%s'. Signed-off-by: Mark Stapp <mjs@cisco.com>
Greptile SummaryThis PR fixes two distinct data-handling bugs in
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["rip_packet_dump():\nRIPv2 AUTH_SIMPLE_PASSWORD RTE"] --> B["p = &rte->prefix\n(raw packet pointer, 16 bytes, no null term)"]
B -->|"OLD: pass p directly to %s"| C["β οΈ zlog_debug(..., p)\npotential buffer over-read"]
B -->|"NEW: copy to local buffer"| D["memset(cbuf, 0, 20)\nmemcpy(cbuf, p, 16)"]
D --> E["β
zlog_debug(..., cbuf)\nnull-terminated, safe"]
F["rip_response_process():\nNexthop not directly reachable"] --> G["rn = route_node_match(rip->table, &p)"]
G -->|"rn != NULL"| H["rn->info is rip_info_list_head *"]
H -->|"OLD: rinfo = rn->info\ntype confusion!"| I["β οΈ rinfo->type dereferences list head"]
H -->|"NEW: rip_info_list_first(rn->info)"| J["rinfo = first rip_info element or NULL"]
J --> K["β
if(rinfo && rinfo->type == ...) safe dereference"]
Last reviewed commit: 4fe4861 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Use data structs correctly in a couple of places; avoid offering a raw pointer from a packet to '%s'.