Branch: Tag:

1999-09-21

1999-09-21 21:16:27 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

some bugfixes in decode_value

Rev: src/encode.c:1.38
Rev: src/testsuite.in:1.198

24:   #include "stuff.h"   #include "version.h"    - RCSID("$Id: encode.c,v 1.37 1999/09/19 22:58:20 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.38 1999/09/21 21:16:26 hubbe Exp $");      #ifdef _AIX   #include <net/nh.h>
645:    what&=T_MASK; \    if(data->ptr + num > data->len || num <0) \    error("Failed to decode string. (string range error)\n"); \ +  if(what<0 || what>2) error("Failed to decode string. (Illegal size shift)\n"); \    STR=begin_wide_shared_string(num, what); \    MEMCPY(STR->str, data->data + data->ptr, num << what); \    data->ptr+=(num << what); \
847:       case T_ARRAY:    { -  struct array *a=allocate_array(num); +  struct array *a; +  if(num < 0) +  error("Failed to decode string. (array size is negative)\n"); +  +  /* Heruetical */ +  if(data->ptr + num > data->len) +  error("Failed to decode array. (not enough data)\n"); +     tmp.type=T_ARRAY; -  tmp.u.array=a; +  tmp.u.array=a=allocate_array(num);    mapping_insert(data->decoded, & data->counter, &tmp);    data->counter.u.integer++;   
875:    if(num<0)    error("Failed to decode string. (mapping size is negative)\n");    +  /* Heruetical */ +  if(data->ptr + num > data->len) +  error("Failed to decode mapping. (not enough data)\n"); +     m=allocate_mapping(num);    tmp.type=T_MAPPING;    tmp.u.mapping=m;
895:       case T_MULTISET:    { -  struct multiset *m=mkmultiset(low_allocate_array(0, num)); +  struct multiset *m; +  if(num<0) +  error("Failed to decode string. (multiset size is negative)\n"); +  +  /* Heruetical */ +  if(data->ptr + num > data->len) +  error("Failed to decode multiset. (not enough data)\n"); +  +  m=mkmultiset(low_allocate_array(0, num));    tmp.type=T_MULTISET;    tmp.u.multiset=m;    mapping_insert(data->decoded, & data->counter, &tmp);