ssl/record/ssl3_record.c:783: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - [0, 254]):unsigned32 by call to `tls1_cbc_remove_padding`.
Showing all 13 steps of the trace


ssl/record/ssl3_record.c:649:1: Parameter `*s->rlayer.rrec.data`
647.    *       an internal error occurred.
648.    */
649. > int tls1_enc(SSL *s, int send)
650.   {
651.       SSL3_RECORD *rec;

ssl/record/ssl3_record.c:783:19: Call
781.               mac_size = EVP_MD_CTX_size(s->read_hash);
782.           if ((bs != 1) && !send)
783.               ret = tls1_cbc_remove_padding(s, rec, bs, mac_size);
                         ^
784.           if (pad && !send)
785.               rec->length -= pad;

ssl/record/ssl3_record.c:1057:1: Parameter `rec->length`
  1055.    *  -1: otherwise.
  1056.    */
  1057. > int tls1_cbc_remove_padding(const SSL *s,
  1058.                               SSL3_RECORD *rec,
  1059.                               unsigned block_size, unsigned mac_size)

ssl/record/ssl3_record.c:1102:30: Call
  1100.   
  1101.       for (i = 0; i < to_check; i++) {
  1102.           unsigned char mask = constant_time_ge_8(padding_length, i);
                                       ^
  1103.           unsigned char b = rec->data[rec->length - 1 - i];
  1104.           /*

include/internal/constant_time_locl.h:160:1: Parameter `a`
    158.   }
    159.   
    160. > static ossl_inline unsigned char constant_time_ge_8(unsigned int a,
    161.                                                       unsigned int b)
    162.   {

include/internal/constant_time_locl.h:163:28: Call
    161.                                                       unsigned int b)
    162.   {
    163.       return (unsigned char)(constant_time_ge(a, b));
                                      ^
    164.   }
    165.   

include/internal/constant_time_locl.h:154:1: Parameter `a`
      152.   }
      153.   
      154. > static ossl_inline unsigned int constant_time_ge(unsigned int a,
      155.                                                    unsigned int b)
      156.   {

include/internal/constant_time_locl.h:157:13: Call
      155.                                                    unsigned int b)
      156.   {
      157.       return ~constant_time_lt(a, b);
                         ^
      158.   }
      159.   

include/internal/constant_time_locl.h:142:1: <LHS trace>
140.   }
141.   
142. > static ossl_inline unsigned int constant_time_lt(unsigned int a,
143.                                                    unsigned int b)
144.   {

include/internal/constant_time_locl.h:142:1: Parameter `a`
        140.   }
        141.   
        142. > static ossl_inline unsigned int constant_time_lt(unsigned int a,
        143.                                                    unsigned int b)
        144.   {

include/internal/constant_time_locl.h:142:1: <RHS trace>
140.   }
141.   
142. > static ossl_inline unsigned int constant_time_lt(unsigned int a,
143.                                                    unsigned int b)
144.   {

include/internal/constant_time_locl.h:142:1: Parameter `b`
        140.   }
        141.   
        142. > static ossl_inline unsigned int constant_time_lt(unsigned int a,
        143.                                                    unsigned int b)
        144.   {

include/internal/constant_time_locl.h:145:12: Binary operation: ([0, +oo] - [0, 254]):unsigned32 by call to `tls1_cbc_remove_padding` 
        143.                                                    unsigned int b)
        144.   {
        145.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
                          ^
        146.   }
        147.   

static ossl_inline unsigned int constant_time_lt(unsigned int a,
                                                 unsigned int b)
{
    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
}
['int tls1_enc(SSL *s, int send)\n{\n    SSL3_RECORD *rec;\n    EVP_CIPHER_CTX *ds;\n    unsigned long l;\n    int bs, i, j, k, pad = 0, ret, mac_size = 0;\n    const EVP_CIPHER *enc;\n    if (send) {\n        if (EVP_MD_CTX_md(s->write_hash)) {\n            int n = EVP_MD_CTX_size(s->write_hash);\n            OPENSSL_assert(n >= 0);\n        }\n        ds = s->enc_write_ctx;\n        rec = RECORD_LAYER_get_wrec(&s->rlayer);\n        if (s->enc_write_ctx == NULL)\n            enc = NULL;\n        else {\n            int ivlen;\n            enc = EVP_CIPHER_CTX_cipher(s->enc_write_ctx);\n            if (SSL_USE_EXPLICIT_IV(s)\n                && EVP_CIPHER_mode(enc) == EVP_CIPH_CBC_MODE)\n                ivlen = EVP_CIPHER_iv_length(enc);\n            else\n                ivlen = 0;\n            if (ivlen > 1) {\n                if (rec->data != rec->input)\n                    fprintf(stderr,\n                            "%s:%d: rec->data != rec->input\\n",\n                            __FILE__, __LINE__);\n                else if (RAND_bytes(rec->input, ivlen) <= 0)\n                    return -1;\n            }\n        }\n    } else {\n        if (EVP_MD_CTX_md(s->read_hash)) {\n            int n = EVP_MD_CTX_size(s->read_hash);\n            OPENSSL_assert(n >= 0);\n        }\n        ds = s->enc_read_ctx;\n        rec = RECORD_LAYER_get_rrec(&s->rlayer);\n        if (s->enc_read_ctx == NULL)\n            enc = NULL;\n        else\n            enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx);\n    }\n    if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) {\n        memmove(rec->data, rec->input, rec->length);\n        rec->input = rec->data;\n        ret = 1;\n    } else {\n        l = rec->length;\n        bs = EVP_CIPHER_block_size(ds->cipher);\n        if (EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {\n            unsigned char buf[EVP_AEAD_TLS1_AAD_LEN], *seq;\n            seq = send ? RECORD_LAYER_get_write_sequence(&s->rlayer)\n                : RECORD_LAYER_get_read_sequence(&s->rlayer);\n            if (SSL_IS_DTLS(s)) {\n                unsigned char dtlsseq[9], *p = dtlsseq;\n                s2n(send ? DTLS_RECORD_LAYER_get_w_epoch(&s->rlayer) :\n                    DTLS_RECORD_LAYER_get_r_epoch(&s->rlayer), p);\n                memcpy(p, &seq[2], 6);\n                memcpy(buf, dtlsseq, 8);\n            } else {\n                memcpy(buf, seq, 8);\n                for (i = 7; i >= 0; i--) {\n                    ++seq[i];\n                    if (seq[i] != 0)\n                        break;\n                }\n            }\n            buf[8] = rec->type;\n            buf[9] = (unsigned char)(s->version >> 8);\n            buf[10] = (unsigned char)(s->version);\n            buf[11] = rec->length >> 8;\n            buf[12] = rec->length & 0xff;\n            pad = EVP_CIPHER_CTX_ctrl(ds, EVP_CTRL_AEAD_TLS1_AAD,\n                                      EVP_AEAD_TLS1_AAD_LEN, buf);\n            if (pad <= 0)\n                return -1;\n            if (send) {\n                l += pad;\n                rec->length += pad;\n            }\n        } else if ((bs != 1) && send) {\n            i = bs - ((int)l % bs);\n            j = i - 1;\n            for (k = (int)l; k < (int)(l + i); k++)\n                rec->input[k] = j;\n            l += i;\n            rec->length += i;\n        }\n        if (!send) {\n            if (l == 0 || l % bs != 0)\n                return 0;\n        }\n        i = EVP_Cipher(ds, rec->data, rec->input, l);\n        if ((EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_CUSTOM_CIPHER)\n            ? (i < 0)\n            : (i == 0))\n            return -1;\n        if (send == 0) {\n            if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE) {\n                rec->data += EVP_GCM_TLS_EXPLICIT_IV_LEN;\n                rec->input += EVP_GCM_TLS_EXPLICIT_IV_LEN;\n                rec->length -= EVP_GCM_TLS_EXPLICIT_IV_LEN;\n            } else if (EVP_CIPHER_mode(enc) == EVP_CIPH_CCM_MODE) {\n                rec->data += EVP_CCM_TLS_EXPLICIT_IV_LEN;\n                rec->input += EVP_CCM_TLS_EXPLICIT_IV_LEN;\n                rec->length -= EVP_CCM_TLS_EXPLICIT_IV_LEN;\n            }\n        }\n        ret = 1;\n        if (!SSL_USE_ETM(s) && EVP_MD_CTX_md(s->read_hash) != NULL)\n            mac_size = EVP_MD_CTX_size(s->read_hash);\n        if ((bs != 1) && !send)\n            ret = tls1_cbc_remove_padding(s, rec, bs, mac_size);\n        if (pad && !send)\n            rec->length -= pad;\n    }\n    return ret;\n}', 'int tls1_cbc_remove_padding(const SSL *s,\n                            SSL3_RECORD *rec,\n                            unsigned block_size, unsigned mac_size)\n{\n    unsigned padding_length, good, to_check, i;\n    const unsigned overhead = 1    + mac_size;\n    if (SSL_USE_EXPLICIT_IV(s)) {\n        if (overhead + block_size > rec->length)\n            return 0;\n        rec->data += block_size;\n        rec->input += block_size;\n        rec->length -= block_size;\n        rec->orig_len -= block_size;\n    } else if (overhead > rec->length)\n        return 0;\n    padding_length = rec->data[rec->length - 1];\n    if (EVP_CIPHER_flags(s->enc_read_ctx->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {\n        rec->length -= padding_length + 1;\n        return 1;\n    }\n    good = constant_time_ge(rec->length, overhead + padding_length);\n    to_check = 255;\n    if (to_check > rec->length - 1)\n        to_check = rec->length - 1;\n    for (i = 0; i < to_check; i++) {\n        unsigned char mask = constant_time_ge_8(padding_length, i);\n        unsigned char b = rec->data[rec->length - 1 - i];\n        good &= ~(mask & (padding_length ^ b));\n    }\n    good = constant_time_eq(0xff, good & 0xff);\n    rec->length -= good & (padding_length + 1);\n    return constant_time_select_int(good, 1, -1);\n}', 'static ossl_inline unsigned char constant_time_ge_8(unsigned int a,\n                                                    unsigned int b)\n{\n    return (unsigned char)(constant_time_ge(a, b));\n}', 'static ossl_inline unsigned int constant_time_ge(unsigned int a,\n                                                 unsigned int b)\n{\n    return ~constant_time_lt(a, b);\n}', 'static ossl_inline unsigned int constant_time_lt(unsigned int a,\n                                                 unsigned int b)\n{\n    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));\n}']