projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: out-of-bound memory access
[babeltrace.git]
/
formats
/
ctf
/
ctf.c
diff --git
a/formats/ctf/ctf.c
b/formats/ctf/ctf.c
index af1809efc8a0390986027bded924e6d2b3bb932e..fb9b2333cf63180a208ace408b9d9b1b90deebc4 100644
(file)
--- a/
formats/ctf/ctf.c
+++ b/
formats/ctf/ctf.c
@@
-863,7
+863,6
@@
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
struct ctf_file_stream *file_stream =
container_of(pos, struct ctf_file_stream, pos);
int ret;
struct ctf_file_stream *file_stream =
container_of(pos, struct ctf_file_stream, pos);
int ret;
- off_t off;
struct packet_index *packet_index, *prev_index;
switch (whence) {
struct packet_index *packet_index, *prev_index;
switch (whence) {
@@
-907,9
+906,11
@@
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
}
pos->content_size = -1U; /* Unknown at this point */
pos->packet_size = WRITE_PACKET_LEN;
}
pos->content_size = -1U; /* Unknown at this point */
pos->packet_size = WRITE_PACKET_LEN;
- off = bt_posix_fallocate(pos->fd, pos->mmap_offset,
- pos->packet_size / CHAR_BIT);
- assert(off == 0);
+ do {
+ ret = bt_posix_fallocate(pos->fd, pos->mmap_offset,
+ pos->packet_size / CHAR_BIT);
+ } while (ret == EINTR);
+ assert(ret == 0);
pos->offset = 0;
} else {
read_next_packet:
pos->offset = 0;
} else {
read_next_packet:
@@
-935,6
+936,11
@@
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
assert(0);
}
assert(0);
}
+ if (pos->cur_index >= pos->packet_index->len) {
+ pos->offset = EOF;
+ return;
+ }
+
packet_index = &g_array_index(pos->packet_index,
struct packet_index, pos->cur_index);
if (pos->cur_index > 0) {
packet_index = &g_array_index(pos->packet_index,
struct packet_index, pos->cur_index);
if (pos->cur_index > 0) {
@@
-947,11
+953,6
@@
void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
ctf_update_current_packet_index(&file_stream->parent,
prev_index, packet_index);
ctf_update_current_packet_index(&file_stream->parent,
prev_index, packet_index);
- if (pos->cur_index >= pos->packet_index->len) {
- pos->offset = EOF;
- return;
- }
-
/*
* We need to check if we are in trace read or called
* from packet indexing. In this last case, the
/*
* We need to check if we are in trace read or called
* from packet indexing. In this last case, the
@@
-2010,7
+2011,7
@@
int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags,
snprintf(index_name, strlen(path) + sizeof(INDEX_PATH),
INDEX_PATH, path);
snprintf(index_name, strlen(path) + sizeof(INDEX_PATH),
INDEX_PATH, path);
- if (
faccessat(td->dirfd, index_name, O_RDONLY, flags
) < 0) {
+ if (
bt_faccessat(td->dirfd, td->parent.path, index_name, O_RDONLY, 0
) < 0) {
ret = create_stream_packet_index(td, file_stream);
if (ret) {
fprintf(stderr, "[error] Stream index creation error.\n");
ret = create_stream_packet_index(td, file_stream);
if (ret) {
fprintf(stderr, "[error] Stream index creation error.\n");
This page took
0.024946 seconds
and
4
git commands to generate.