handle case where keylist_in_out is NULL sync
authorVolker Birk <vb@pep.foundation>
Sun, 21 Oct 2018 12:16:32 +0200
branchsync
changeset 3081094fa0544427
parent 3080 16fe89d2bc89
child 3082 e865e13adf75
handle case where keylist_in_out is NULL
src/message_api.c
     1.1 --- a/src/message_api.c	Sun Oct 21 12:12:03 2018 +0200
     1.2 +++ b/src/message_api.c	Sun Oct 21 12:16:32 2018 +0200
     1.3 @@ -2432,32 +2432,34 @@
     1.4          verify_curr->next = orig_verify;
     1.5      }
     1.6  
     1.7 -    /* append keylist to signers */
     1.8 -    if (keylist_in_out && *keylist_in_out && (*keylist_in_out)->value) {
     1.9 -        stringlist_t** tail_pp = &verify_curr->next;
    1.10 -        
    1.11 -        while (*tail_pp) {
    1.12 -            tail_pp = &((*tail_pp)->next);
    1.13 +    if (keylist_in_out) {
    1.14 +        /* append keylist to signers */
    1.15 +        if (*keylist_in_out && (*keylist_in_out)->value) {
    1.16 +            stringlist_t** tail_pp = &verify_curr->next;
    1.17 +
    1.18 +            while (*tail_pp) {
    1.19 +                tail_pp = &((*tail_pp)->next);
    1.20 +            }
    1.21 +            stringlist_t* second_list = *keylist_in_out;
    1.22 +            if (second_list) {
    1.23 +                char* listhead_val = second_list->value;
    1.24 +                if (!listhead_val || listhead_val[0] == '\0') {
    1.25 +                    /* remove head, basically. This can happen when,
    1.26 +                       for example, the signature is detached and
    1.27 +                       verification is not seen directly after
    1.28 +                       decryption, so no signer is presumed in
    1.29 +                       the first construction of the keylist */
    1.30 +                    *keylist_in_out = (*keylist_in_out)->next;
    1.31 +                    second_list->next = NULL;
    1.32 +                    free_stringlist(second_list);
    1.33 +                }
    1.34 +            }
    1.35 +            *tail_pp = *keylist_in_out;
    1.36          }
    1.37 -        stringlist_t* second_list = *keylist_in_out;
    1.38 -        if (second_list) {
    1.39 -            char* listhead_val = second_list->value;
    1.40 -            if (!listhead_val || listhead_val[0] == '\0') {
    1.41 -                /* remove head, basically. This can happen when,
    1.42 -                   for example, the signature is detached and
    1.43 -                   verification is not seen directly after
    1.44 -                   decryption, so no signer is presumed in
    1.45 -                   the first construction of the keylist */
    1.46 -                *keylist_in_out = (*keylist_in_out)->next;
    1.47 -                second_list->next = NULL;
    1.48 -                free_stringlist(second_list);
    1.49 -            }
    1.50 -        }
    1.51 -        *tail_pp = *keylist_in_out;
    1.52 +
    1.53 +        *keylist_in_out = verify_curr;
    1.54      }
    1.55 -    
    1.56 -    *keylist_in_out = verify_curr;
    1.57 -    
    1.58 +
    1.59      status = PEP_STATUS_OK;
    1.60      
    1.61  free: