JSON-26: ENGINE-198: Put in some short engine checks on encrypt/decrypt retvals. Technically, they shouldn't return with a NULL message value to mime decode/encode without an accompanying bad status, but since it's being hit with one of the apps, we'll make sure.
authorKrista Bennett <krista@pep-project.org>
Tue, 02 May 2017 02:11:09 +0200
changeset 1742fe5c1dc9d028
parent 1739 73374beaca6f
child 1744 4d42c179c6bb
JSON-26: ENGINE-198: Put in some short engine checks on encrypt/decrypt retvals. Technically, they shouldn't return with a NULL message value to mime decode/encode without an accompanying bad status, but since it's being hit with one of the apps, we'll make sure.
src/message_api.c
     1.1 --- a/src/message_api.c	Fri Apr 28 19:03:21 2017 +0200
     1.2 +++ b/src/message_api.c	Tue May 02 02:11:09 2017 +0200
     1.3 @@ -2569,6 +2569,11 @@
     1.4          goto pep_error;
     1.5      }
     1.6  
     1.7 +    if (!dec_msg) {
     1.8 +        status = PEP_UNKNOWN_ERROR;
     1.9 +        goto pep_error;
    1.10 +    }
    1.11 +
    1.12      status = mime_encode_message(dec_msg, false, mime_plaintext);
    1.13  
    1.14      if (status == PEP_STATUS_OK)
    1.15 @@ -2614,6 +2619,12 @@
    1.16      if (status != PEP_STATUS_OK)
    1.17          goto pep_error;
    1.18  
    1.19 +
    1.20 +    if (!enc_msg) {
    1.21 +        status = PEP_UNKNOWN_ERROR;
    1.22 +        goto pep_error;
    1.23 +    }
    1.24 +
    1.25      status = mime_encode_message(enc_msg, false, mime_ciphertext);
    1.26  
    1.27  pep_error:
    1.28 @@ -2652,6 +2663,11 @@
    1.29                                        flags);
    1.30      if (status != PEP_STATUS_OK)
    1.31          goto pep_error;
    1.32 + 
    1.33 +    if (!enc_msg) {
    1.34 +        status = PEP_UNKNOWN_ERROR;
    1.35 +        goto pep_error;
    1.36 +    }
    1.37  
    1.38      status = mime_encode_message(enc_msg, false, mime_ciphertext);
    1.39