Branch: Tag:

2016-05-17

2016-05-17 14:47:56 by Per Hedbor <ph@opera.com>

Use the same exponentiation result size limit in both locations, and set it to 1G

1891:    MP_INT *mi;    INT_TYPE size = (INT_TYPE)mpz_size(THIS);    + #define POW_RAM_LIMIT (1024*1024*1024) +     if (args != 1)    SIMPLE_WRONG_NUM_ARGS_ERROR ("pow", 1);    if (TYPEOF(sp[-1]) == T_INT) {
1898:    if (e < 0)    SIMPLE_ARG_ERROR ("pow", 1, "Negative exponent.");    /* Cut off at 1 MB. */ -  if (INT_TYPE_MUL_OVERFLOW(e, size) || size * e > (INT_TYPE)(0x100000/sizeof(mp_limb_t))) { +  if (INT_TYPE_MUL_OVERFLOW(e, size) || size * e > (INT_TYPE)(POW_RAM_LIMIT/sizeof(mp_limb_t))) {    if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0)    goto too_large;    }
1911:    SIMPLE_ARG_ERROR ("pow", 1, "Negative exponent.");    i=mpz_get_si(mi);    /* Cut off at 100 MB. */ -  if(mpz_cmp_si(mi, i) || INT_TYPE_MUL_OVERFLOW(size, i) || (size*i>(INT_TYPE)(0x10000000/sizeof(mp_limb_t)))) +  if(mpz_cmp_si(mi, i) || INT_TYPE_MUL_OVERFLOW(size, i) || (size*i>(INT_TYPE)(POW_RAM_LIMIT/sizeof(mp_limb_t))))    {    if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0)    SIMPLE_ARG_ERROR ("pow", 1, "Exponent too large.");