Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
libtac: fix double free in tac_acct_read_timeout
Browse files Browse the repository at this point in the history
Core dumped due:
"free(): double free detected in tcache 2"

re->msg should be freed by the caller as in comment 6380c5a, else
it will create a dangling pointer.

Fixes: 6380c5a ("Replace deprecated bcopy() by memcpy()")
Signed-off-by: Loïc Sang <loic.sang@6wind.com>
  • Loading branch information
Loïc Sang committed Oct 11, 2023
1 parent 4284d90 commit a6c2742
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libtac/lib/acct_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ int tac_acct_read_timeout(int fd, struct areply *re, unsigned long timeout)
msg = (char *)xcalloc(1, tb->msg_len + 1);
memcpy(msg, (unsigned char *)tb + TAC_ACCT_REPLY_FIXED_FIELDS_SIZE, tb->msg_len);
msg[(int)tb->msg_len] = '\0';
re->msg = msg;
free(msg);
re->msg = msg; /* Freed by caller */
}

/* server logged our request successfully */
Expand Down

0 comments on commit a6c2742

Please sign in to comment.