[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] net/filter-rewriter.c: Fix trace_event print bug
From: |
Zhang Chen |
Subject: |
[Qemu-devel] [PATCH] net/filter-rewriter.c: Fix trace_event print bug |
Date: |
Fri, 14 Apr 2017 14:27:15 +0800 |
Because of inet_ntoa() return a statically allocated buffer,
subsequent calls will overwrite, So we fix this bug.
Signed-off-by: Zhang Chen <address@hidden>
---
net/filter-rewriter.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index 91cf6b2..aad00b4 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -69,8 +69,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf,
tcp_pkt = (struct tcphdr *)pkt->transport_header;
if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
+ char ip_src[20], ip_dst[20];
+
+ strcpy(ip_src, inet_ntoa(pkt->ip->ip_src));
+ strcpy(ip_dst, inet_ntoa(pkt->ip->ip_dst));
+
trace_colo_filter_rewriter_pkt_info(__func__,
- inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
+ ip_src, ip_dst,
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
tcp_pkt->th_flags);
trace_colo_filter_rewriter_conn_offset(conn->offset);
@@ -144,8 +149,13 @@ static int handle_secondary_tcp_pkt(RewriterState *rf,
tcp_pkt = (struct tcphdr *)pkt->transport_header;
if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
+ char ip_src[20], ip_dst[20];
+
+ strcpy(ip_src, inet_ntoa(pkt->ip->ip_src));
+ strcpy(ip_dst, inet_ntoa(pkt->ip->ip_dst));
+
trace_colo_filter_rewriter_pkt_info(__func__,
- inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
+ ip_src, ip_dst,
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
tcp_pkt->th_flags);
trace_colo_filter_rewriter_conn_offset(conn->offset);
--
2.7.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] net/filter-rewriter.c: Fix trace_event print bug,
Zhang Chen <=