[PATCH 31/38] trace-cmd listen: prevent a infinite loop in communicate_with_client()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The loop used to read the option is obviously wrong. If the option
isn't read with one call to read(), it will loop indefinitely. Move
the setting of the initial values out of the loop.

Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx>
---
 tracecmd/trace-listen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
index da46d09e..af9e3454 100644
--- a/tracecmd/trace-listen.c
+++ b/tracecmd/trace-listen.c
@@ -452,9 +452,9 @@ static int communicate_with_client(struct tracecmd_msg_handle *msg_handle)
 				goto out;
 
 			ret = -EIO;
+			t = size;
+			s = 0;
 			do {
-				t = size;
-				s = 0;
 				s = read(fd, option+s, t);
 				if (s <= 0) {
 					free(option);
-- 
2.44.0





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux