Add missing permission notice in each source file
[babeltrace.git] / formats / ctf / ctf.c
index 37e314849c611844065e0605ef7fa3dbfafabce9..18a560132582ac9002535658734b51cb3abe68e8 100644 (file)
  *
  * 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 <babeltrace/format.h>
@@ -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 (;;) {
@@ -1940,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;
This page took 0.023177 seconds and 4 git commands to generate.