<div dir="ltr"><div>From 52e90e362e5413de4d424bc12102077402f6144f Mon Sep 17 00:00:00 2001</div><div>From: wangfan <<a href="mailto:wangfan1985@gmail.com">wangfan1985@gmail.com</a>></div><div>Date: Thu, 30 May 2013 10:22:46 +0800</div>
<div>Subject: [PATCH] sheep: return directly when sending data fails.</div><div><br></div><div><span class="" style="white-space:pre"> </span>when send data fails,do_client_rx will free struct client_info.</div><div><span class="" style="white-space:pre"> </span>call do_client_tx will access freed memory.</div>
<div><br></div><div>Signed-off-by: wangfan <<a href="mailto:wangfan1985@gmail.com">wangfan1985@gmail.com</a>></div><div>---</div><div> sheep/request.c | 11 +++++++----</div><div> 1 files changed, 7 insertions(+), 4 deletions(-)</div>
<div><br></div><div>diff --git a/sheep/request.c b/sheep/request.c</div><div>index e99f6f2..91e1f06 100644</div><div>--- a/sheep/request.c</div><div>+++ b/sheep/request.c</div><div>@@ -613,12 +613,13 @@ static inline void finish_rx(struct client_info *ci)</div>
<div> <span class="" style="white-space:pre"> </span>queue_request(req);</div><div> }</div><div> </div><div>-static void do_client_rx(struct client_info *ci)</div><div>+static int do_client_rx(struct client_info *ci)</div>
<div> {</div><div> <span class="" style="white-space:pre"> </span>if (begin_rx(ci) < 0)</div><div>-<span class="" style="white-space:pre"> </span>return;</div><div>+<span class="" style="white-space:pre"> </span>return -1;</div>
<div> </div><div> <span class="" style="white-space:pre"> </span>finish_rx(ci);</div><div>+<span class="" style="white-space:pre"> </span>return SD_RES_SUCCESS;</div><div> }</div><div> </div><div> static void init_tx_hdr(struct client_info *ci)</div>
<div>@@ -810,8 +811,10 @@ static void client_handler(int fd, int events, void *data)</div><div> <span class="" style="white-space:pre"> </span>if (events & (EPOLLERR | EPOLLHUP) || is_conn_dead(&ci->conn))</div>
<div> <span class="" style="white-space:pre"> </span>return clear_client_info(ci);</div><div> </div><div>-<span class="" style="white-space:pre"> </span>if (events & EPOLLIN)</div><div>-<span class="" style="white-space:pre"> </span>do_client_rx(ci);</div>
<div>+<span class="" style="white-space:pre"> </span>if (events & EPOLLIN) {</div><div>+<span class="" style="white-space:pre"> </span>if (do_client_rx(ci) < 0)</div><div>+<span class="" style="white-space:pre"> </span>return;</div>
<div>+<span class="" style="white-space:pre"> </span>}</div><div> </div><div> <span class="" style="white-space:pre"> </span>if (events & EPOLLOUT)</div><div> <span class="" style="white-space:pre"> </span>do_client_tx(ci);</div>
<div>-- </div><div>1.7.1</div><div><br></div></div>