Branch: Tag:

2003-10-11

2003-10-11 16:35:17 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added shift limit at 0x800000 for `<<() and ``<<().

Rev: src/modules/Gmp/mpz_glue.c:1.153

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: mpz_glue.c,v 1.152 2003/08/07 14:56:32 jhs Exp $ + || $Id: mpz_glue.c,v 1.153 2003/10/11 16:35:17 grubba Exp $   */      #include "global.h" - RCSID("$Id: mpz_glue.c,v 1.152 2003/08/07 14:56:32 jhs Exp $"); + RCSID("$Id: mpz_glue.c,v 1.153 2003/10/11 16:35:17 grubba Exp $");   #include "gmp_machine.h"   #include "module.h"   
1550:    mpz_mul_2exp(OBTOMPZ(res), THIS, sp[-1].u.integer);    } else {    mi = get_mpz(sp-1, 1, "Gmp.mpz->`<<", 1, 1); -  if(!mpz_fits_ulong_p (mi)) -  { +     if(mpz_sgn(mi)<0)    SIMPLE_ARG_ERROR ("Gmp.mpz->`<<", 1, "Got negative shift count."); -  +  /* Cut off at 1MB ie 0x800000 bits. */ +  if(!mpz_fits_ulong_p(mi) || (mpz_get_ui(THIS) > 0x800000)) +  {    if(mpz_sgn(THIS))    SIMPLE_ARG_ERROR ("Gmp.mpz->`<<", 1, "Shift count too large.");    else {
1625:       if (args != 1)    SIMPLE_WRONG_NUM_ARGS_ERROR ("Gmp.mpz->``<<", 1); -  mi = get_mpz(sp-1, 1, "Gmp.mpz->``<<", 1, 1); -  -  if(!mpz_fits_ulong_p (THIS)) { +     if(mpz_sgn(THIS) < 0)    Pike_error ("Gmp.mpz->``<<(): Got negative shift count.\n"); -  +  +  mi = get_mpz(sp-1, 1, "Gmp.mpz->``<<", 1, 1); +  +  /* Cut off at 1MB ie 0x800000 bits. */ +  if(!mpz_fits_ulong_p(THIS) || (mpz_get_ui(THIS) > 0x800000)) {    if(mpz_sgn(mi))    Pike_error ("Gmp.mpz->``<<(): Shift count too large.\n");    else {