Verified Commit 0f7d1503 authored by Tomáš Stefan's avatar Tomáš Stefan
Browse files

fn param checks, new test file

parent 5d1eada7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
#include "types.h"


xref_t *xref_init();
xref_t *xref_init(void);

void xref_free(xref_t *xref);

+19 −4
Original line number Diff line number Diff line
@@ -113,6 +113,9 @@ sigil_err_t pdf_peek_char(sigil_t *sgl, char *result)
{
    sigil_err_t err;

    if (sgl == NULL || result == NULL)
        return ERR_PARAMETER;

    err = pdf_get_char(sgl, result);
    if (err != ERR_NO)
        return err;
@@ -392,6 +395,9 @@ sigil_err_t parse_number(sigil_t *sgl, size_t *number)
    char c;
    int digits = 0;

    if (sgl == NULL || number == NULL)
        return ERR_PARAMETER;

    *number = 0;

    err = skip_leading_whitespaces(sgl);
@@ -469,7 +475,7 @@ sigil_err_t parse_indirect_reference(sigil_t *sgl, reference_t *ref)
    return ERR_NO;
}

// parse the key of the couple key - value in the dictionary
// parse the key of the pair key - value in the dictionary
sigil_err_t parse_dict_key(sigil_t *sgl, dict_key_t *dict_key)
{
    sigil_err_t err;
@@ -477,6 +483,9 @@ sigil_err_t parse_dict_key(sigil_t *sgl, dict_key_t *dict_key)
    char tmp[DICT_KEY_MAX],
         c;

    if (sgl == NULL || dict_key == NULL)
        return ERR_PARAMETER;

    sigil_zeroize(tmp, DICT_KEY_MAX * sizeof(*tmp));

    if (parse_word(sgl, ">>") == ERR_NO)
@@ -599,7 +608,7 @@ sigil_err_t reference_to_offset(sigil_t *sgl, const reference_t *ref, size_t *re
{
    xref_entry_t *xref_entry;

    if (sgl == NULL || ref == NULL || sgl->xref == NULL)
    if (sgl == NULL || ref == NULL || sgl->xref == NULL || result == NULL)
        return ERR_PARAMETER;

    if (sgl->xref->capacity <= ref->object_num)
@@ -651,7 +660,7 @@ const char *sigil_err_string(sigil_err_t err)

void print_module_name(const char *module_name, int verbosity)
{
    if (verbosity < 1)
    if (verbosity < 1 || module_name == NULL)
        return;

    printf("\n + Testing module: %s\n", module_name);
@@ -671,7 +680,7 @@ void print_module_result(int result, int verbosity)

void print_test_item(const char *test_name, int verbosity)
{
    if (verbosity < 2)
    if (verbosity < 2 || test_name == NULL)
        return;

    printf("    - %-32s", test_name);
@@ -693,6 +702,9 @@ sigil_t *test_prepare_sgl_content(char *content, size_t size)
{
    sigil_t *sgl;

    if (content == NULL)
        return NULL;

    if (sigil_init(&sgl) != ERR_NO)
        return NULL;

@@ -708,6 +720,9 @@ sigil_t *test_prepare_sgl_path(const char *path)
{
    sigil_t *sgl;

    if (path == NULL)
        return NULL;

    if (sigil_init(&sgl) != ERR_NO)
        return NULL;

+9 −3
Original line number Diff line number Diff line
@@ -237,6 +237,9 @@ sigil_err_t load_digest(sigil_t *sgl)
    const X509_ALGOR        *tmp_alg = NULL;
    const ASN1_OCTET_STRING *tmp_hash = NULL;

    if (sgl == NULL || sgl->contents == NULL || sgl->certificates)
        return ERR_PARAMETER;

    contents = sgl->contents->contents_hex;
    contents_len = strlen(contents);

@@ -387,6 +390,9 @@ sigil_err_t compare_digest(sigil_t *sgl)

    sgl->hash_cmp_result = HASH_CMP_RESULT_DIFFER;

    if (sgl->md_hash == NULL || sgl->computed_digest == NULL)
        return ERR_PARAMETER;

    if (ASN1_STRING_cmp(sgl->md_hash, sgl->computed_digest) == 0)
        sgl->hash_cmp_result = HASH_CMP_RESULT_MATCH;

@@ -397,11 +403,11 @@ sigil_err_t verify_digest(sigil_t *sgl, int *result)
{
    sigil_err_t err;

    *result = 1;

    if (sgl == NULL)
    if (sgl == NULL || *result == NULL)
        return ERR_PARAMETER;

    *result = 1;

    err = compute_digest_pkcs1(sgl);
    if (err != ERR_NO)
        return err;
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ static sigil_err_t parse_subfilter(sigil_t *sgl)
    char tmp[SUBFILTER_MAX],
            c;

    if (sgl == NULL)
        return ERR_PARAMETER;

    sigil_zeroize(tmp, SUBFILTER_MAX * sizeof(*tmp));

    err = parse_word(sgl, "/");
@@ -58,6 +61,9 @@ static sigil_err_t parse_byte_range(sigil_t *sgl)
    size_t start,
           length;

    if (sgl == NULL)
        return ERR_PARAMETER;

    err = parse_word(sgl, "[");
    if (err != ERR_NO)
        return err;
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@ sigil_err_t find_sig_field(sigil_t *sgl)
    dict_key_t dict_key;
    int other_ft;

    if (sgl == NULL)
        return ERR_PARAMETER;

    err = ERR_NO_DATA;

    for (size_t i = 0; i < sgl->fields.capacity; i++) {
Loading