Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] [PATCH babeltrace] Fix lint warnings
@ 2013-11-15  0:40 Jérémie Galarneau
  2013-11-15  2:02 ` Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Jérémie Galarneau @ 2013-11-15  0:40 UTC (permalink / raw)


** CID 1125105: Unchecked close() return value
formats/ctf/writer/stream.c: 521

** CID 1124085: Use after free
formats/ctf/writer/event-fields.c: 1128

** CID 1124088: Dereference before null check
formats/ctf/writer/stream.c: 371

Signed-off-by: J?r?mie Galarneau <jeremie.galarneau at efficios.com>
---
 formats/ctf/writer/event-fields.c | 7 +++++--
 formats/ctf/writer/stream.c       | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/formats/ctf/writer/event-fields.c b/formats/ctf/writer/event-fields.c
index 30fe578..ff970c0 100644
--- a/formats/ctf/writer/event-fields.c
+++ b/formats/ctf/writer/event-fields.c
@@ -1125,7 +1125,10 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field,
 	while (!ctf_pos_access_ok(pos,
 		offset_align(pos->offset,
 			field->type->declaration->alignment))) {
-		increase_packet_size(pos);
+		ret = increase_packet_size(pos);
+		if (ret) {
+			goto end;
+		}
 	}
 
 	ctf_align_pos(pos, field->type->declaration->alignment);
@@ -1139,7 +1142,7 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field,
 			break;
 		}
 	}
-
+end:
 	return ret;
 }
 
diff --git a/formats/ctf/writer/stream.c b/formats/ctf/writer/stream.c
index f03f170..ac89429 100644
--- a/formats/ctf/writer/stream.c
+++ b/formats/ctf/writer/stream.c
@@ -368,7 +368,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
 	int ret = 0;
 	size_t i;
 	uint64_t timestamp_begin, timestamp_end;
-	struct bt_ctf_stream_class *stream_class = stream->stream_class;
+	struct bt_ctf_stream_class *stream_class;
 	struct bt_ctf_field *integer = NULL;
 	struct ctf_stream_pos packet_context_pos;
 
@@ -385,6 +385,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
 		stream->flush.func(stream, stream->flush.data);
 	}
 
+	stream_class = stream->stream_class;
 	timestamp_begin = ((struct bt_ctf_event *) g_ptr_array_index(
 		stream->events, 0))->timestamp;
 	timestamp_end = ((struct bt_ctf_event *) g_ptr_array_index(
@@ -518,7 +519,9 @@ void bt_ctf_stream_destroy(struct bt_ctf_ref *ref)
 
 	stream = container_of(ref, struct bt_ctf_stream, ref_count);
 	ctf_fini_pos(&stream->pos);
-	close(stream->pos.fd);
+	if (close(stream->pos.fd)) {
+		perror("close");
+	}
 	bt_ctf_stream_class_put(stream->stream_class);
 	g_ptr_array_free(stream->events, TRUE);
 	g_free(stream);
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [lttng-dev] [PATCH babeltrace] Fix lint warnings
  2013-11-15  0:40 [lttng-dev] [PATCH babeltrace] Fix lint warnings Jérémie Galarneau
@ 2013-11-15  2:02 ` Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2013-11-15  2:02 UTC (permalink / raw)


----- Original Message -----
> From: "J?r?mie Galarneau" <jeremie.galarneau@efficios.com>
> To: lttng-dev at lists.lttng.org
> Sent: Thursday, November 14, 2013 7:40:57 PM
> Subject: [lttng-dev] [PATCH babeltrace] Fix lint warnings
> 
> ** CID 1125105: Unchecked close() return value
> formats/ctf/writer/stream.c: 521
> 
> ** CID 1124085: Use after free
> formats/ctf/writer/event-fields.c: 1128
> 
> ** CID 1124088: Dereference before null check
> formats/ctf/writer/stream.c: 371

Merged, thanks!

Mathieu

> 
> Signed-off-by: J?r?mie Galarneau <jeremie.galarneau at efficios.com>
> ---
>  formats/ctf/writer/event-fields.c | 7 +++++--
>  formats/ctf/writer/stream.c       | 7 +++++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/formats/ctf/writer/event-fields.c
> b/formats/ctf/writer/event-fields.c
> index 30fe578..ff970c0 100644
> --- a/formats/ctf/writer/event-fields.c
> +++ b/formats/ctf/writer/event-fields.c
> @@ -1125,7 +1125,10 @@ int bt_ctf_field_structure_serialize(struct
> bt_ctf_field *field,
>  	while (!ctf_pos_access_ok(pos,
>  		offset_align(pos->offset,
>  			field->type->declaration->alignment))) {
> -		increase_packet_size(pos);
> +		ret = increase_packet_size(pos);
> +		if (ret) {
> +			goto end;
> +		}
>  	}
>  
>  	ctf_align_pos(pos, field->type->declaration->alignment);
> @@ -1139,7 +1142,7 @@ int bt_ctf_field_structure_serialize(struct
> bt_ctf_field *field,
>  			break;
>  		}
>  	}
> -
> +end:
>  	return ret;
>  }
>  
> diff --git a/formats/ctf/writer/stream.c b/formats/ctf/writer/stream.c
> index f03f170..ac89429 100644
> --- a/formats/ctf/writer/stream.c
> +++ b/formats/ctf/writer/stream.c
> @@ -368,7 +368,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
>  	int ret = 0;
>  	size_t i;
>  	uint64_t timestamp_begin, timestamp_end;
> -	struct bt_ctf_stream_class *stream_class = stream->stream_class;
> +	struct bt_ctf_stream_class *stream_class;
>  	struct bt_ctf_field *integer = NULL;
>  	struct ctf_stream_pos packet_context_pos;
>  
> @@ -385,6 +385,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
>  		stream->flush.func(stream, stream->flush.data);
>  	}
>  
> +	stream_class = stream->stream_class;
>  	timestamp_begin = ((struct bt_ctf_event *) g_ptr_array_index(
>  		stream->events, 0))->timestamp;
>  	timestamp_end = ((struct bt_ctf_event *) g_ptr_array_index(
> @@ -518,7 +519,9 @@ void bt_ctf_stream_destroy(struct bt_ctf_ref *ref)
>  
>  	stream = container_of(ref, struct bt_ctf_stream, ref_count);
>  	ctf_fini_pos(&stream->pos);
> -	close(stream->pos.fd);
> +	if (close(stream->pos.fd)) {
> +		perror("close");
> +	}
>  	bt_ctf_stream_class_put(stream->stream_class);
>  	g_ptr_array_free(stream->events, TRUE);
>  	g_free(stream);
> --
> 1.8.4.2
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-15  2:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-15  0:40 [lttng-dev] [PATCH babeltrace] Fix lint warnings Jérémie Galarneau
2013-11-15  2:02 ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox