704 |
704 |
705 // convert ObjectConfig to HTTPObjectConfig |
705 // convert ObjectConfig to HTTPObjectConfig |
706 |
706 |
707 // add objects |
707 // add objects |
708 conf->nobj = ucx_dlist_size(cfg->objects); |
708 conf->nobj = ucx_dlist_size(cfg->objects); |
709 conf->objects = pool_calloc(pool, 1, sizeof(httpd_object*)); |
709 conf->objects = pool_calloc(pool, conf->nobj, sizeof(httpd_object*)); |
710 |
710 |
711 UcxDlist *objlist = cfg->objects; |
711 UcxDlist *objlist = cfg->objects; |
712 int i = 0; |
712 int i = 0; |
713 while(objlist != NULL) { |
713 while(objlist != NULL) { |
714 ConfigObject *cob = objlist->data; |
714 ConfigObject *cob = objlist->data; |
725 |
725 |
726 // create and add object |
726 // create and add object |
727 httpd_object *obj = object_new(pool, name); |
727 httpd_object *obj = object_new(pool, name); |
728 obj->path = NULL; |
728 obj->path = NULL; |
729 |
729 |
730 conf->objects[i] = obj; // TODO: beyond array bounds write |
730 conf->objects[i] = obj; |
731 |
731 |
732 // add directives |
732 // add directives |
733 for(int i=0;i<6;i++) { |
733 for(int i=0;i<6;i++) { |
734 UcxDlist *dirs = cob->directives[i]; |
734 UcxDlist *dirs = cob->directives[i]; |
735 while(dirs != NULL) { |
735 while(dirs != NULL) { |
736 ConfigDirective *cfgdir = dirs->data; |
736 ConfigDirective *cfgdir = dirs->data; |
737 |
737 |
738 directive *d = pool_malloc(pool, sizeof(directive)); |
738 directive *d = pool_malloc(pool, sizeof(directive)); |
739 d->cond = NULL; |
739 if(cfgdir->condition) { |
|
740 sstr_t expr = cfgdir->condition->param_str; |
|
741 d->cond = condition_from_str(pool, expr.ptr, expr.length); |
|
742 } else { |
|
743 d->cond = NULL; |
|
744 } |
740 d->param = pblock_create_pool(pool, 8); |
745 d->param = pblock_create_pool(pool, 8); |
741 |
746 |
742 // add params |
747 // add params |
743 UcxList *param = cfg_param_list(cfgdir->value, mp); |
748 UcxList *param = cfg_param_list(cfgdir->value, mp); |
744 while(param != NULL) { |
749 while(param != NULL) { |