crypto/sm2/sm2_crypt.c:102: error: INTEGER_OVERFLOW_L2
  ([2, 2147483646] + [0, 2147483644]):signed32 by call to `ASN1_object_size`.
Showing all 10 steps of the trace


crypto/sm2/sm2_crypt.c:90:1: Parameter `digest->md_size`
88.   }
89.   
90. > int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
91.                           size_t *ct_size)
92.   {

crypto/sm2/sm2_crypt.c:94:25: Call
92.   {
93.       const size_t field_size = ec_field_size(EC_KEY_get0_group(key));
94.       const int md_size = EVP_MD_size(digest);
                              ^
95.       size_t sz;
96.   

crypto/evp/evp_lib.c:509:9: Assignment
  507.       if (md == NULL) {
  508.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  509.           return -1;
                 ^
  510.       }
  511.   

crypto/sm2/sm2_crypt.c:94:5: Assignment
92.   {
93.       const size_t field_size = ec_field_size(EC_KEY_get0_group(key));
94.       const int md_size = EVP_MD_size(digest);
          ^
95.       size_t sz;
96.   

crypto/sm2/sm2_crypt.c:102:12: Call
100.       /* Integer and string are simple type; set constructed = 0, means primitive and definite length encoding. */
101.       sz = 2 * ASN1_object_size(0, field_size + 1, V_ASN1_INTEGER)
102.            + ASN1_object_size(0, md_size, V_ASN1_OCTET_STRING)
                  ^
103.            + ASN1_object_size(0, msg_len, V_ASN1_OCTET_STRING);
104.       /* Sequence is structured type; set constructed = 1, means constructed and definite length encoding. */

crypto/asn1/asn1_lib.c:215:1: <LHS trace>
213.   }
214.   
215. > int ASN1_object_size(int constructed, int length, int tag)
216.   {
217.       int ret = 1;

crypto/asn1/asn1_lib.c:215:1: Parameter `length`
  213.   }
  214.   
  215. > int ASN1_object_size(int constructed, int length, int tag)
  216.   {
  217.       int ret = 1;

crypto/asn1/asn1_lib.c:215:1: <RHS trace>
213.   }
214.   
215. > int ASN1_object_size(int constructed, int length, int tag)
216.   {
217.       int ret = 1;

crypto/asn1/asn1_lib.c:215:1: Parameter `length`
  213.   }
  214.   
  215. > int ASN1_object_size(int constructed, int length, int tag)
  216.   {
  217.       int ret = 1;

crypto/asn1/asn1_lib.c:240:5: Binary operation: ([2, 2147483646] + [0, 2147483644]):signed32 by call to `ASN1_object_size` 
  238.       if (ret >= INT_MAX - length)
  239.           return -1;
  240.       return ret + length;
             ^
  241.   }
  242.   

int ASN1_object_size(int constructed, int length, int tag)
{
    int ret = 1;
    if (length < 0)
        return -1;
    if (tag >= 31) {
        while (tag > 0) {
            tag >>= 7;
            ret++;
        }
    }
    if (constructed == 2) {
        ret += 3;
    } else {
        ret++;
        if (length > 127) {
            int tmplen = length;
            while (tmplen > 0) {
                tmplen >>= 8;
                ret++;
            }
        }
    }
    if (ret >= INT_MAX - length)
        return -1;
    return ret + length;
}
['int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,\n                        size_t *ct_size)\n{\n    const size_t field_size = ec_field_size(EC_KEY_get0_group(key));\n    const int md_size = EVP_MD_size(digest);\n    size_t sz;\n    if (field_size == 0 || md_size < 0)\n        return 0;\n    sz = 2 * ASN1_object_size(0, field_size + 1, V_ASN1_INTEGER)\n         + ASN1_object_size(0, md_size, V_ASN1_OCTET_STRING)\n         + ASN1_object_size(0, msg_len, V_ASN1_OCTET_STRING);\n    *ct_size = ASN1_object_size(1, sz, V_ASN1_SEQUENCE);\n    return 1;\n}', 'int EVP_MD_size(const EVP_MD *md)\n{\n    int ok, v = md->md_size;\n    OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };\n    if (md == NULL) {\n        EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);\n        return -1;\n    }\n    params[0] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_SIZE, &v);\n    ok = evp_do_md_getparams(md, params);\n    return ok != 0 ? v : -1;\n}', 'int ASN1_object_size(int constructed, int length, int tag)\n{\n    int ret = 1;\n    if (length < 0)\n        return -1;\n    if (tag >= 31) {\n        while (tag > 0) {\n            tag >>= 7;\n            ret++;\n        }\n    }\n    if (constructed == 2) {\n        ret += 3;\n    } else {\n        ret++;\n        if (length > 127) {\n            int tmplen = length;\n            while (tmplen > 0) {\n                tmplen >>= 8;\n                ret++;\n            }\n        }\n    }\n    if (ret >= INT_MAX - length)\n        return -1;\n    return ret + length;\n}']