From aa5d2472fc257fd2b674e424c47f356e8cfb9fe5 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Mon, 20 Sep 2021 14:38:56 +0530 Subject: [PATCH] Use strerror_r() instead of strerror() Change-Id: I8360ca2084a8a08ec4f8f219384c6c7516870035 Signed-off-by: Nishant Chaprana --- plugin/online-monitor/online-monitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/online-monitor/online-monitor.c b/plugin/online-monitor/online-monitor.c index b2bde47..3c61e10 100755 --- a/plugin/online-monitor/online-monitor.c +++ b/plugin/online-monitor/online-monitor.c @@ -64,6 +64,7 @@ static int open_raw_socket(const char *ifname) { struct sockaddr_ll sock_ll; int sock; + char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, }; sock = socket(PF_PACKET, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, htons(ETH_P_ALL)); if (sock < 0) { @@ -77,7 +78,8 @@ static int open_raw_socket(const char *ifname) sock_ll.sll_protocol = htons(ETH_P_ALL); if (bind(sock, (struct sockaddr *)&sock_ll, sizeof(sock_ll)) < 0) { - ERR("bind failed, ifname %s error %s\n", ifname, strerror(errno)); + ERR("bind failed, ifname %s error %s\n", ifname, + strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER)); close(sock); return -1; } -- 2.7.4