Branch: Tag:

2003-11-17

2003-11-17 14:39:48 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added more paranoia before accepting dumped bytecode.

Rev: src/encode.c:1.200
Rev: src/opcodes.c:1.159
Rev: src/opcodes.h:1.37
Rev: src/version.h:1.345

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: encode.c,v 1.199 2003/11/15 17:25:05 mast Exp $ + || $Id: encode.c,v 1.200 2003/11/17 14:39:47 grubba Exp $   */      #include "global.h"
29:   #include "bignum.h"   #include "pikecode.h"   #include "pike_types.h" + #include "opcodes.h"    - RCSID("$Id: encode.c,v 1.199 2003/11/15 17:25:05 mast Exp $"); + RCSID("$Id: encode.c,v 1.200 2003/11/17 14:39:47 grubba Exp $");      /* #define ENCODE_DEBUG */   
1193:    */    code_number(PIKE_BYTECODE_METHOD, data);    + #ifdef PIKE_USE_MACHINE_CODE +  /* Add the checksum of the instrs array. */ +  code_number(instrs_checksum, data); + #endif /* PIKE_USE_MACHINE_CODE */ +     /* program */   #ifdef ENCODE_PROGRAM   #ifdef PIKE_DEBUG
3359:    Pike_error("Unsupported byte-code method: %d\n", bytecode_method);    }    + #ifdef PIKE_USE_MACHINE_CODE +  { +  size_t csum; +  /* Check the checksum of the instrs array. */ +  decode_number(csum, data); +  if (csum != instrs_checksum) { +  Pike_error("Bad instruction checksum: %d (expected %d)\n", +  csum, instrs_checksum); +  } +  } + #endif /* PIKE_USE_MACHINE_CODE */ +     /* Decode program */    if (data->ptr + (int)local_num_program >= data->len) {    Pike_error("Failed to decode program. (string too short)\n");