/* #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"
-/* from modules.c */
-extern void init_builtin_modules(dict_t *dict);
-
static struct cloc no_loc={"none",0};
struct atomlist {
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);
context=root;
/* Predefined keys for boolean values */
+ /* "nowise" and "verily" have the advantage of being the same
+ length, so they line up nicely... thanks VKC and SGT (who also
+ point out that "mayhap" is a good "maybe" value as well) */
i=new_item(t_bool,no_loc);
i->data.bool=False;
false=list_append(NULL,i);
dict_add(root,"no",false);
dict_add(root,"No",false);
dict_add(root,"NO",false);
+ dict_add(root,"nowise",false);
+ dict_add(root,"Nowise",false);
+ dict_add(root,"NOWISE",false);
dict_add(root,"true",true);
dict_add(root,"True",true);
dict_add(root,"TRUE",true);
dict_add(root,"yes",true);
dict_add(root,"Yes",true);
dict_add(root,"YES",true);
+ dict_add(root,"verily",true);
+ dict_add(root,"Verily",true);
+ dict_add(root,"VERILY",true);
add_closure(root,"makelist",makelist);
add_closure(root,"readfile",readfile);
{
uint32_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;
}
-list_t *list_copy(list_t *a)
+static list_t *list_copy(list_t *a)
{
list_t *r, *i, *b, *l;
closure_t *c;
c=safe_malloc(sizeof(*c),"add_closure");
c->description=name;
+ c->type=CL_PURE;
c->apply=apply;
c->interface=NULL;
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;
}