X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=18a560132582ac9002535658734b51cb3abe68e8;hp=ccc103c586d612cda7877e9168c6c5da22565a8e;hb=c462e188f3e7819c7bc74f671038cdbf36e8c3c0;hpb=f824ae0446c7a1ef3acd5d8e30c039c4ed7381ce diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index ccc103c5..18a56013 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -16,6 +16,14 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ #include @@ -583,11 +591,11 @@ int ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags) int ctf_fini_pos(struct ctf_stream_pos *pos) { - int ret; - if (pos->prot == PROT_WRITE && pos->content_size_loc) *pos->content_size_loc = pos->offset; if (pos->base_mma) { + int ret; + /* unmap old base */ ret = munmap_align(pos->base_mma); if (ret) { @@ -902,6 +910,9 @@ int ctf_open_trace_metadata_packet_read(struct ctf_trace *td, FILE *in, return -EINVAL; } + if ((header.content_size / CHAR_BIT) < header_sizeof(header)) + return -EINVAL; + toread = (header.content_size / CHAR_BIT) - header_sizeof(header); for (;;) { @@ -1028,7 +1039,6 @@ int ctf_open_trace_metadata_read(struct ctf_trace *td, metadata_stream->pos.fd = openat(td->dirfd, "metadata", O_RDONLY); if (metadata_stream->pos.fd < 0) { fprintf(stderr, "Unable to open metadata.\n"); - g_free(metadata_stream); ret = -1; goto end_free; } @@ -1941,9 +1951,11 @@ static int ctf_close_trace(struct trace_descriptor *tdp) { struct ctf_trace *td = container_of(tdp, struct ctf_trace, parent); - int i, ret; + int ret; if (td->streams) { + int i; + for (i = 0; i < td->streams->len; i++) { struct ctf_stream_declaration *stream; int j;