pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:2279:    do { \    INT32 what, e; \    INT64 num; \    DECODE("decode_entry"); \    if((what & TAG_MASK) != (X)) \    decode_error(data, NULL, "Wrong bits (%d).\n", what & TAG_MASK); \    (Y)=num; \    } while(0);      #define getdata2(S,L) do { \ -  if(data->ptr + (ptrdiff_t)(sizeof(S[0])*(L)) > data->len) \ +  if(sizeof(S[0])*(L) > (size_t)(data->len - data->ptr)) \    decode_error(data, NULL, "String range error.\n"); \    MEMCPY((S),(data->data + data->ptr), sizeof(S[0])*(L)); \    data->ptr+=sizeof(S[0])*(L); \    }while(0)      #if PIKE_BYTEORDER == 4321   #define BITFLIP(S)   #else   #define BITFLIP(S) \    switch(what) \
pike.git/src/encode.c:2894:       case TAG_ARRAY:    {    struct array *a;    TYPE_FIELD types;    if(num < 0)    decode_error(data, NULL,    "Failed to decode array (array size is negative).\n");       /* Heruetical */ -  if(data->ptr + num > data->len) +  if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode array (not enough data).\n");       EDB(2,fprintf(stderr, "%*sDecoding array of size %d to <%d>\n",    data->depth, "", num, entry_id.u.integer));       SETUP_DECODE_MEMOBJ(T_ARRAY, array, a, allocate_array(num),    free_svalues(ITEM(a), a->size, a->type_field));       types = 0;    for(e=0;e<num;e++)
pike.git/src/encode.c:2923:    }       case TAG_MAPPING:    {    struct mapping *m;    if(num<0)    decode_error(data, NULL, "Failed to decode mapping "    "(mapping size is negative).\n");       /* Heuristical */ -  if(data->ptr + num > data->len) +  if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode mapping "    "(not enough data).\n");       EDB(2,fprintf(stderr, "%*sDecoding mapping of size %d to <%d>\n",    data->depth, "", num, entry_id.u.integer));       SETUP_DECODE_MEMOBJ(T_MAPPING, mapping, m, allocate_mapping(num), ; );       for(e=0;e<num;e++)    {
pike.git/src/encode.c:2953:    case TAG_MULTISET:    {    struct multiset *m;    struct array *a;    TYPE_FIELD types;    if(num<0)    decode_error(data, NULL, "Failed to decode multiset "    "(multiset size is negative).\n");       /* Heruetical */ -  if(data->ptr + num > data->len) +  if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode multiset "    "(not enough data).\n");       /* NOTE: This code knows stuff about the implementation of multisets...*/       EDB(2,fprintf(stderr, "%*sDecoding multiset of size %d to <%d>\n",    data->depth, "", num, entry_id.u.integer));    SETUP_DECODE_MEMOBJ (T_MULTISET, multiset, m,    allocate_multiset (0, 0, NULL), ;);    /* FIXME: This array could be avoided by building the multiset directly. */
pike.git/src/encode.c:4144: Inside #if defined(PIKE_USE_MACHINE_CODE)
   decode_number(csum, data);    if (csum != instrs_checksum) {    decode_error(data, NULL,    "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) { +  if (local_num_program >= (size_t)(data->len - data->ptr)) {    decode_error(data, NULL,    "Failed to decode program (string too short).\n");    }    low_add_many_to_program(Pike_compiler,    (PIKE_OPCODE_T *)(data->data + data->ptr),    local_num_program);    data->ptr += local_num_program * sizeof(PIKE_OPCODE_T);       /* Decode relocations */    for (e=0; e<(int)local_num_relocations; e++) {
pike.git/src/encode.c:4168:    add_to_relocations(reloc);    }       /* Perform relocation. */   #ifdef DECODE_PROGRAM    DECODE_PROGRAM(p);   #endif /* DECODE_PROGRAM */    make_program_executable(p);       /* Decode linenumbers */ -  if (data->ptr + (int)local_num_linenumbers >= data->len) { +  if (local_num_linenumbers >= (size_t)(data->len - data->ptr)) {    decode_error(data, NULL, "Failed to decode linenumbers "    "(string too short).\n");    }    for (e=0; e<(int)local_num_linenumbers; e++) {    char lineno_info;    lineno_info = *(data->data + data->ptr++);    add_to_linenumbers(lineno_info);    }       /* Now with the linenumber info in place it gets useful to