/* #define DUMP_PARSE_TREE */
#include "secnet.h"
+#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "conffile.h"
#include "conffile_internal.h"
+#include "conffile.yy.h"
#include "util.h"
#include "ipaddr.h"
struct dict *parent;
struct searchlist *search;
struct entry *entries;
- uint32_t size;
+ int32_t size;
};
static struct atomlist *atoms=NULL;
return "**unknown**";
}
-static void ptree_indent(uint32_t amount)
+static void ptree_indent(int amount)
{
- uint32_t i;
+ int i;
for (i=0; i<amount; i++) printf(" . ");
}
default: printf("**unknown primitive type**\n"); break;
}
} else {
+ assert(d<INT_MAX);
printf("%s: (%s line %d)\n",ntype(n->type),n->loc.file,n->loc.line);
ptree_indent(d);
printf(" |-"); ptree_dump(n->l, d+1);
return NULL;
}
-uint32_t list_length(list_t *a)
+int32_t list_length(list_t *a)
{
- uint32_t l=0;
+ int32_t l=0;
list_t *i;
- for (i=a; i; i=i->next) l++;
+ for (i=a; i; i=i->next) { assert(l < INT_MAX); l++; }
return l;
}
return list_append_list(list,l);
}
-item_t *list_elem(list_t *l, uint32_t index)
+item_t *list_elem(list_t *l, int32_t index)
{
if (!l) return NULL;
if (index==0) return l->item;
if (i->type!=t_string) {
cfgfatal(loc,desc,"\"%s\" must be a string\n",key);
}
+ if (strlen(i->data.string) > INT_MAX/10) {
+ cfgfatal(loc,desc,"\"%s\" is unreasonably long\n",key);
+ }
r=i->data.string;
return r;
}
if (i->type!=t_number) {
cfgfatal(loc,desc,"\"%s\" must be a number\n",key);
}
+ if (i->data.number >= 0x80000000) {
+ cfgfatal(loc,desc,"\"%s\" must fit into a 32-bit signed integer\n",key);
+ }
r=i->data.number;
return r;
}