Skip to content

Commit

Permalink
Merge pull request FRRouting#20 from ranjanyash54/fix_crash
Browse files Browse the repository at this point in the history
cmgd: fix crash for get-data  with certain xpaths
  • Loading branch information
pushpasis authored Aug 19, 2021
2 parents 5e8e865 + e9b8ccb commit c58f5b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmgd/cmgd_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ int cmgd_db_lookup_data_nodes(
xpath += 2;

strncpy(base_xpath, xpath, sizeof(base_xpath));
remove_slash_at_the_end(base_xpath);

return (cmgd_walk_db_nodes(db_ctxt, base_xpath, NULL, NULL, NULL,
dxpaths, dnodes, nbnodes, num_nodes,
Expand Down Expand Up @@ -462,6 +463,8 @@ int cmgd_db_iter_data(
if (!db_ctxt)
return -1;

remove_slash_at_the_end(base_xpath);

strncpy(xpath, base_xpath, sizeof(xpath));

CMGD_DB_DBG(" -- START DB walk for DBid: %d", db_ctxt->db_id);
Expand Down
3 changes: 3 additions & 0 deletions cmgd/cmgd_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#define FOREACH_CMGD_DB_ID(id) \
for ((id) = CMGD_DB_NONE; (id) < CMGD_DB_MAX_ID; (id)++)

#define remove_slash_at_the_end(str) \
if (str[strlen(str) - 1] == '/') str[strlen(str) - 1] = '\0'

typedef uintptr_t cmgd_db_hndl_t;

typedef void (*cmgd_db_node_iter_fn)(cmgd_db_hndl_t db_hndl,
Expand Down

0 comments on commit c58f5b6

Please sign in to comment.