Project

General

Profile

Bug #3095

Feature #3089: want ::typedef

libctf does not validate arrays correctly

Added by Robert Mustacchi almost 8 years ago. Updated almost 7 years ago.

Status:
Resolved
Priority:
Normal
Category:
lib - userland libraries
Start date:
2012-08-19
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Currently libctf does no validation when using the ctf_create_array() function. All it currently checks is that the arinfo is not NULL, it does not check that the type of the index or that the type of the underlying array itself is currently valid. When adding a struct member we do validate that the member's type is valid so we should do this here.

Here is a simple program that reproduces this problem:

#include <stdio.h>
#include <libctf.h>

int
main(void)
{
        int errp;
        ctf_file_t *fp;
        ctf_id_t id; 
        ctf_arinfo_t arp;

        fp = ctf_create(&errp);
        if (fp == NULL) {
                fprintf(stderr, "failed to create ctf container\n");
                return (1);
        }   

        arp.ctr_contents = 100;
        arp.ctr_index = 101;
        arp.ctr_nelems = 20; 
        if (ctf_add_array(fp, CTF_ADD_ROOT, &arp) != CTF_ERR) {
                fprintf(stderr, "Uh... this shouldn't have worked\n");
                return (1);
        }   

        fprintf(stderr, "ctf_add_array failed: %s\n",
            ctf_errmsg(ctf_errno(fp)));
        return (0);
}

History

#1

Updated by Robert Mustacchi almost 8 years ago

  • % Done changed from 0 to 90
#2

Updated by Robert Mustacchi almost 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 90 to 100

Resolved in 0a47c91c895e274dd0990009919e30e984364a8b.

Also available in: Atom PDF