Skip to content

Commit 12a34f7

Browse files
Fix dangling pointer glusterd_ac_send_friend_remove_req()
In `glusterd-sm.c` we always use use gf_strdup when assigning the peername, preventing a potential crash or invalid memory access But glusterd_ac_send_friend_remove_req() was inadvertely assigning directly, without using `strdup`, which caused a dangling pointer problem which could potentially crash the application. This commit fixes that problem by using the `strdup()` pattern instead of the dangerous direct assignment.
1 parent 895642d commit 12a34f7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

xlators/mgmt/glusterd/src/glusterd-sm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ glusterd_ac_send_friend_remove_req(glusterd_friend_sm_event_t *event,
479479
ret = glusterd_friend_sm_new_event(event_type, &new_event);
480480

481481
if (!ret) {
482-
new_event->peername = peerinfo->hostname;
482+
new_event->peername = gf_strdup(peerinfo->hostname);
483483
gf_uuid_copy(new_event->peerid, peerinfo->uuid);
484484
ret = glusterd_friend_sm_inject_event(new_event);
485485
} else {

0 commit comments

Comments
 (0)