[ltt-dev] [UST PATCH] Fix ustcomm header size

David Goulet david.goulet at polymtl.ca
Mon Oct 4 15:49:33 EDT 2010


Change the type value of size in the ustcomm_header struct
to be size_t and compatible with iov_len and strlen return
value.

Remove a peek_header validation that was useless for size
less than zero since size is now size_t and for a simple
list_markers command, the size was over 800 bytes so the
validation > 100 was hit a lot of times and useless.

Add a return error on malloc failure.

Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
 libustcomm/ustcomm.c |    4 +---
 libustcomm/ustcomm.h |    2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c
index 50038cb..52957b5 100644
--- a/libustcomm/ustcomm.c
+++ b/libustcomm/ustcomm.c
@@ -370,12 +370,10 @@ int ustcomm_recv_fd(int sock,
 	msg.msg_iovlen = 1;
 
 	if (peek_header.size) {
-		if (peek_header.size < 0 || peek_header.size > 100) {
-			WARN("big peek header! %d", peek_header.size);
-		}
 		*data = malloc(peek_header.size);
 		if (!*data) {
 			ERR("failed to allocate space for message");
+			return -1;
 		}
 
 		iov[1].iov_base = (char *)*data;
diff --git a/libustcomm/ustcomm.h b/libustcomm/ustcomm.h
index f3c07b6..6b770b2 100644
--- a/libustcomm/ustcomm.h
+++ b/libustcomm/ustcomm.h
@@ -35,7 +35,7 @@ struct ustcomm_sock {
 
 struct ustcomm_header {
 	int type;
-	long size;
+	size_t size;
 	int command;
 	int response;
 	int fd_included;
-- 
1.7.3.1





More information about the lttng-dev mailing list