Changeset 278

Show
Ignore:
Timestamp:
06/01/10 19:37:33 (20 months ago)
Author:
ol
Message:

Change error handler behaviour. ows/wfs_error don't die with EXIT anymore. Related to fast-cgi implementation. Add exit boolean in ows struct to indicate if we need/can continue to process code.

Location:
trunk/src
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/ows/ows.c

    r277 r278  
    5858    assert(o != NULL); 
    5959 
     60    o->exit = false; 
    6061    o->request = NULL; 
    6162    o->cgi = NULL; 
     
    6364    o->pg = NULL; 
    6465    o->pg_dsn = NULL; 
    65     o->output = NULL; 
     66    o->output = stdout; 
    6667    o->config_file = NULL; 
    6768    o->online_resource = NULL; 
     
    101102    assert(output != NULL); 
    102103 
     104    fprintf(output, "exit : %d\n", o->exit?1:0); 
     105 
    103106    if (o->config_file != NULL) { 
    104107        fprintf(output, "config_file: "); 
     
    264267 
    265268 
    266 int main(int argc, char *argv[]) 
    267 { 
    268     char *query; 
    269     ows *o; 
    270  
    271     o = ows_init(); 
    272     o->config_file = buffer_init(); 
    273  
    274     /* Config Files */ 
    275     if (getenv("TINYOWS_CONFIG_FILE") != NULL) 
    276         buffer_add_str(o->config_file, getenv("TINYOWS_CONFIG_FILE")); 
    277     else 
    278         buffer_add_str(o->config_file, OWS_CONFIG_FILE_PATH); 
    279  
    280     o->output = stdout; 
    281  
    282  
    283     /* retrieve the query in HTTP request */ 
    284     query = cgi_getback_query(o); 
    285  
    286     /* Parse the configuration file and initialize ows struct */ 
    287     ows_parse_config(o, o->config_file->buf); 
    288  
    289     /* Connect the ows to the database */ 
    290     ows_pg(o, o->pg_dsn->buf); 
    291  
    292     /* Fill layers storage metadata */ 
    293     ows_layers_storage_fill(o); 
    294  
    295     /* Open Log file */ 
    296     if (o->log_file != NULL) 
    297         o->log = fopen(o->log_file->buf, "a"); 
    298  
    299  
    300 #if TINYOWS_FCGI 
    301    while (FCGI_Accept() >= 0) 
    302    { 
    303  
    304 #endif 
    305  
    306     query = cgi_getback_query(o); 
    307  
    308     /* Usage or Version command line options */ 
    309     if (query == NULL || strlen(query) == 0) { 
    310         if (argc > 1) { 
    311  
    312                 if (    !strncmp(argv[1], "--help", 6) 
    313                      || !strncmp(argv[1], "-h", 2)      
    314                      || !strncmp(argv[1], "--check", 7)) 
    315                         ows_usage(o); 
    316  
    317                 else if (    !strncmp(argv[1], "--version", 9)  
    318                           || !strncmp(argv[1], "-v", 2)) 
    319                         printf("%s\n", TINYOWS_VERSION); 
    320  
    321                 else ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    322                              "Service Unknown", "service"); 
    323  
    324                 return EXIT_SUCCESS; 
    325         } 
    326  
    327     }  
    328  
    329  
    330     /* Log input query if asked */ 
    331    if (o->log != NULL) 
    332         fprintf(o->log, "[QUERY]\n%s\n---\n", query); 
    333  
    334     o->request = ows_request_init(); 
    335  
     269static void ows_kvp_or_xml(ows *o, char *query) 
     270{ 
    336271    /* 
    337272     * Request encoding and HTTP method WFS 1.1.0 -> 6.5 
     
    354289                 !strcmp(getenv("CONTENT_TYPE"), "text/plain")) 
    355290            o->request->method = OWS_METHOD_XML; 
    356  
    357291        /* Command line Unit Test cases with XML values (not HTTP) */ 
    358292    } else if (!cgi_method_post() && !cgi_method_get() && query[0] == '<') 
     
    362296    else ows_error(o, OWS_ERROR_REQUEST_HTTP, "Wrong HTTP request Method", "http"); 
    363297 
    364     switch (o->request->method) { 
    365         case OWS_METHOD_KVP: 
    366             o->cgi = cgi_parse_kvp(o, query); 
    367             break; 
    368         case OWS_METHOD_XML: 
    369             o->cgi = cgi_parse_xml(o, query); 
    370             break; 
    371  
    372         default: ows_error(o, OWS_ERROR_REQUEST_HTTP, 
     298} 
     299 
     300 
     301int main(int argc, char *argv[]) 
     302{ 
     303    ows *o; 
     304    char *query=NULL; 
     305 
     306    o = ows_init(); 
     307    o->config_file = buffer_init(); 
     308 
     309    /* Config Files */ 
     310    if (getenv("TINYOWS_CONFIG_FILE") != NULL) 
     311        buffer_add_str(o->config_file, getenv("TINYOWS_CONFIG_FILE")); 
     312    else 
     313        buffer_add_str(o->config_file, OWS_CONFIG_FILE_PATH); 
     314 
     315    /* Parse the configuration file and initialize ows struct */ 
     316    if (!o->exit) ows_parse_config(o, o->config_file->buf); 
     317 
     318    /* Connect the ows to the database */ 
     319    if (!o->exit) ows_pg(o, o->pg_dsn->buf); 
     320 
     321    /* Fill layers storage metadata */ 
     322    if (!o->exit) ows_layers_storage_fill(o); 
     323 
     324    /* Open Log file */ 
     325    if (o->log_file != NULL) 
     326        o->log = fopen(o->log_file->buf, "a"); 
     327 
     328 
     329#if TINYOWS_FCGI 
     330   while (FCGI_Accept() >= 0) 
     331   { 
     332#endif 
     333 
     334    if (!o->exit) query = cgi_getback_query(o); 
     335 
     336    /* Usage or Version command line options */ 
     337    if (query == NULL || strlen(query) == 0) { 
     338        if (argc > 1) { 
     339 
     340                if (    !strncmp(argv[1], "--help", 6) 
     341                     || !strncmp(argv[1], "-h", 2)      
     342                     || !strncmp(argv[1], "--check", 7)) 
     343                        ows_usage(o); 
     344 
     345                else if (    !strncmp(argv[1], "--version", 9)  
     346                          || !strncmp(argv[1], "-v", 2)) 
     347                        printf("%s\n", TINYOWS_VERSION); 
     348 
     349                else ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
     350                             "Service Unknown", "service"); 
     351 
     352                o->exit = true; 
     353        } 
     354    }  
     355 
     356 
     357    /* Log input query if asked */ 
     358   if (o->log != NULL) 
     359        fprintf(o->log, "[QUERY]\n%s\n---\n", query); 
     360 
     361    o->request = ows_request_init(); 
     362    if (!o->exit) ows_kvp_or_xml(o, query); 
     363 
     364    if (!o->exit) { 
     365 
     366        switch (o->request->method) { 
     367            case OWS_METHOD_KVP: 
     368                o->cgi = cgi_parse_kvp(o, query); 
     369                break; 
     370            case OWS_METHOD_XML: 
     371                o->cgi = cgi_parse_xml(o, query); 
     372                break; 
     373 
     374            default: ows_error(o, OWS_ERROR_REQUEST_HTTP, 
    373375                        "Wrong HTTP request Method", "http"); 
    374     } 
    375  
    376     o->psql_requests = list_init(); 
     376        } 
     377    } 
     378 
     379    if (!o->exit) o->psql_requests = list_init(); 
    377380 
    378381    /* Fill service's metadata */ 
    379     ows_metadata_fill(o, o->cgi); 
     382    if (!o->exit) ows_metadata_fill(o, o->cgi); 
    380383 
    381384    /* Process service request */ 
    382     ows_request_check(o, o->request, o->cgi, query); 
     385    if (!o->exit) ows_request_check(o, o->request, o->cgi, query); 
    383386 
    384387    /* Run the right OWS service */ 
    385     switch (o->request->service) { 
    386         case WFS: 
    387             o->request->request.wfs = wfs_request_init(); 
    388             wfs_request_check(o, o->request->request.wfs, o->cgi); 
    389             wfs(o, o->request->request.wfs); 
    390             break; 
    391         default: 
    392             ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
     388    if (!o->exit) { 
     389        switch (o->request->service) { 
     390            case WFS: 
     391                o->request->request.wfs = wfs_request_init(); 
     392                wfs_request_check(o, o->request->request.wfs, o->cgi); 
     393                if (!o->exit) wfs(o, o->request->request.wfs); 
     394                break; 
     395            default: 
     396                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    393397                      "Service Unknown", "service"); 
    394     } 
    395  
    396     ows_request_free(o->request); 
    397     o->request=NULL; 
     398        } 
     399    } 
     400 
     401    if (o->request) { 
     402        ows_request_free(o->request); 
     403        o->request=NULL; 
     404    } 
    398405 
    399406#if TINYOWS_FCGI 
     
    401408    OS_LibShutdown(); 
    402409#endif 
    403  
    404410    if (o->log) fclose (o->log); 
    405411    ows_free(o); 
  • trunk/src/ows/ows.h

    r267 r278  
    409409 
    410410typedef struct Ows { 
     411    bool exit; 
    411412    PGconn * pg; 
    412413    buffer * config_file; 
  • trunk/src/ows/ows_config.c

    r248 r278  
    686686static void ows_config_check(ows * o) 
    687687{ 
    688     if (o->online_resource == NULL) 
     688    if (o->online_resource == NULL) { 
    689689        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    690690                  "No 'online_resource' property in tinyows element", 
    691691                  "parse_config_file"); 
    692  
    693     if (o->schema_dir == NULL) 
     692        return; 
     693    } 
     694 
     695    if (o->schema_dir == NULL) { 
    694696        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    695697                  "No 'schema_dir' property in tinyows element", 
    696698                  "parse_config_file"); 
    697  
    698     if (o->metadata == NULL) 
     699        return; 
     700    } 
     701 
     702    if (o->metadata == NULL) { 
    699703        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    700704                  "No 'metadata' element", "parse_config_file"); 
    701  
    702     if (o->metadata->name == NULL) 
     705        return; 
     706    } 
     707 
     708    if (o->metadata->name == NULL) { 
    703709        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    704710                  "No 'name' property in metadata element", 
    705711                  "parse_config_file"); 
    706  
    707     if (o->metadata->title == NULL) 
     712        return; 
     713    } 
     714 
     715    if (o->metadata->title == NULL) { 
    708716        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    709717                  "No 'title' property in metadata element", 
    710718                  "parse_config_file"); 
    711  
    712     if (o->pg_dsn == NULL) 
     719        return; 
     720    } 
     721 
     722    if (o->pg_dsn == NULL) { 
    713723        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    714724                  "No 'pg' element", 
    715725                  "parse_config_file"); 
    716  
    717     if (o->contact == NULL) 
     726        return; 
     727    } 
     728 
     729    if (o->contact == NULL) { 
    718730        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    719731                  "No 'contact' element", 
    720732                  "parse_config_file"); 
    721  
    722     if (o->contact->name == NULL) 
     733        return; 
     734    } 
     735 
     736    if (o->contact->name == NULL) { 
    723737        ows_error(o, OWS_ERROR_CONFIG_FILE, 
    724738                  "No 'name' property in contact element", 
    725739                  "parse_config_file"); 
     740        return; 
     741    } 
    726742} 
    727743 
     
    746762        ows_error(o, OWS_ERROR_CONFIG_FILE, "Unable to open config file !", 
    747763                  "parse_config_file"); 
     764        return; 
    748765    } 
    749766 
     
    786803        ows_error(o, OWS_ERROR_CONFIG_FILE, "Unable to open config file !", 
    787804                  "parse_config_file"); 
     805        return; 
    788806    } 
    789807 
  • trunk/src/ows/ows_error.c

    r276 r278  
    7575    assert(locator != NULL); 
    7676 
     77    assert(!o->exit); 
     78    o->exit = true; 
     79 
    7780    if (o->log != NULL) 
    7881        fprintf(o->log, "[ERROR] {%s:%s} %s\n", 
     
    9396    fprintf(o->output, " </ows:Exception>\n"); 
    9497    fprintf(o->output, "</ows:ExceptionReport>\n"); 
    95  
    96 #if 0 
    97 #if TINYOWS_FCGI 
    98     OS_LibShutdown(); 
    99 #endif 
    100 #endif 
    101  
    102    if (o->log) fclose (o->log); 
    103    ows_free(o); 
    104    exit(EXIT_SUCCESS); 
    10598} 
    106  
    10799 
    108100/* 
  • trunk/src/ows/ows_metadata.c

    r116 r278  
    203203        ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    204204                  "service unknown", "service"); 
     205        return; 
    205206    } 
    206207 
  • trunk/src/ows/ows_request.c

    r248 r278  
    218218    } else { 
    219219        /* check if version format is x.y.z */ 
    220         if (b->use < 5) 
     220        if (b->use < 5) { 
    221221            ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    222222                      "VERSION parameter is not valid (use x.y.z)", "version"); 
     223            return v; 
     224        } 
    223225 
    224226        l = list_explode('.', b); 
     
    228230            ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    229231                      "VERSION parameter is not valid (use x.y.z)", "version"); 
     232            return v; 
    230233        } 
    231234 
     
    240243            ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    241244                      "VERSION parameter is not valid (use x.y.z)", "version"); 
     245            return v; 
    242246        } 
    243247 
     
    277281        /* Tests WFS 1.1.0 require a default value for requests 
    278282           encoded in XML if service is not set */ 
    279         if (cgi_method_get()) 
     283        if (cgi_method_get()) { 
    280284            ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    281285                      "SERVICE is not set", "SERVICE"); 
    282         else { 
     286            return; 
     287        } else { 
    283288            if (buffer_case_cmp(o->metadata->type, "WMS")) 
    284289                or->service = WMS; 
    285290            else if (buffer_case_cmp(o->metadata->type, "WFS")) 
    286291                or->service = WFS; 
    287             else 
     292            else { 
    288293                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    289294                          "service unknown", "service"); 
     295                return; 
     296            } 
    290297        } 
    291298    } else { 
     
    296303        else if (buffer_case_cmp(b, "WFS")) 
    297304            or->service = WFS; 
    298         else if (buffer_case_cmp(b, "WCS")) 
    299             ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    300                       "service not implemented", "service"); 
    301305        else if (buffer_case_cmp(b, "")) { 
    302306            if (buffer_case_cmp(o->metadata->type, "WMS")) 
     
    304308            else if (buffer_case_cmp(o->metadata->type, "WFS")) 
    305309                or->service = WFS; 
    306             else 
     310            else {  
    307311                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    308312                          "service unknown", "service"); 
    309         } else 
    310             ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
     313                return; 
     314            } 
     315        } else { 
     316                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    311317                      "service unknown", "service"); 
     318                return; 
     319        } 
    312320    } 
    313321 
    314322 
    315323    /* check if REQUEST is set */ 
    316     if (!array_is_key(cgi, "request")) 
     324    if (!array_is_key(cgi, "request")) { 
    317325        ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    318326                  "REQUEST is not set", "REQUEST"); 
    319     else 
    320         b = array_get(cgi, "request"); 
     327        return; 
     328    } else b = array_get(cgi, "request"); 
    321329 
    322330    /* check if VERSION is set and init Version */ 
     
    326334        if (!buffer_case_cmp(b, "GetCapabilities")) { 
    327335            /* WFS 1.1.0 with KVP need a version set */ 
    328             if (o->request->method == OWS_METHOD_KVP) 
     336            if (o->request->method == OWS_METHOD_KVP) { 
    329337                ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    330338                          "VERSION is not set", "VERSION"); 
     339                return; 
     340            } 
    331341            /* WFS 1.1.0 require a default value for requests 
    332342               encoded in XML if version is not set */ 
     
    342352    /* check if layers have name or title and srs */ 
    343353    for (ln = o->layers->first; ln != NULL; ln = ln->next) { 
    344         if (ln->layer->name == NULL) 
     354        if (ln->layer->name == NULL) { 
    345355            ows_error(o, OWS_ERROR_CONFIG_FILE, 
    346356                      "No layer name defined", "config_file"); 
     357            return; 
     358        } 
    347359 
    348360        if (ows_layer_match_table(o, ln->layer->name)) { 
    349             if (ln->layer->title == NULL) 
     361            if (ln->layer->title == NULL) { 
    350362                ows_error(o, OWS_ERROR_CONFIG_FILE, 
    351363                          "No layer title defined", "config_file"); 
     364                return; 
     365            } 
    352366 
    353367            if (or->service == WFS) { 
    354                 if (ln->layer->prefix == NULL) 
     368                if (ln->layer->prefix == NULL) { 
    355369                    ows_error(o, OWS_ERROR_CONFIG_FILE, 
    356370                              "No layer prefix defined", "config_file"); 
    357  
    358                 if (ln->layer->server == NULL) 
     371                    return; 
     372                } 
     373 
     374                if (ln->layer->server == NULL) { 
    359375                    ows_error(o, OWS_ERROR_CONFIG_FILE, 
    360376                              "No layer server defined", "config_file"); 
     377                    return; 
     378                } 
    361379            } 
    362380 
     
    371389                        if (!check_regexp(b->buf, "^http://www.opengis.net") 
    372390                                && !check_regexp(b->buf, "^EPSG") 
    373                                 && !check_regexp(b->buf, "^urn:")) 
     391                                && !check_regexp(b->buf, "^urn:")) { 
    374392                            ows_error(o, OWS_ERROR_CONFIG_FILE, 
    375393                                      "srsname isn't valid", "srsName"); 
     394                            return; 
     395                        } 
    376396 
    377397                        for (srid = ln->layer->srid->first; srid != NULL; 
     
    381401                        } 
    382402 
    383                         if (srsname == false) 
     403                        if (srsname == false) { 
    384404                            ows_error(o, OWS_ERROR_CONFIG_FILE, 
    385405                                      "srsname doesn't match srid", 
    386406                                      "config_file"); 
     407                            return; 
     408                        } 
    387409                    } 
    388410                } 
     
    425447            buffer_free(xmlstring); 
    426448             
    427             if (valid != 0) 
     449            if (valid != 0) { 
    428450                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    429451                      "xml isn't valid", "request"); 
     452                return; 
     453            } 
    430454        } 
    431455    } 
  • trunk/src/ows/ows_storage.c

    r216 r278  
    170170        ows_error(o, OWS_ERROR_REQUEST_SQL_FAILED, 
    171171                  "Unable to access pg_* tables.", "not_null columns"); 
     172        return; 
    172173    } 
    173174 
     
    221222        ows_error(o, OWS_ERROR_REQUEST_SQL_FAILED, 
    222223                  "Unable to access pg_* tables.", "pkey column"); 
     224        return; 
    223225    } 
    224226 
     
    248250            ows_error(o, OWS_ERROR_REQUEST_SQL_FAILED, 
    249251                  "Unable to find pkey column number.", "pkey_column number"); 
     252            return; 
    250253        } 
    251254 
     
    271274            ows_error(o, OWS_ERROR_REQUEST_SQL_FAILED, 
    272275                  "Unable to use pg_get_serial_sequence.", "pkey_sequence retrieve"); 
     276            return; 
    273277        } 
    274278         
     
    320324        ows_error(o, OWS_ERROR_REQUEST_SQL_FAILED, 
    321325                  "Unable to access pg_* tables.", "fill_attributes"); 
     326        return; 
    322327    } 
    323328 
     
    364369                  "Some layer(s) described in config file are not available in geometry_columns or geography_columns", 
    365370                  "storage"); 
     371        return; 
    366372    } 
    367373 
  • trunk/src/struct/cgi_request.c

    r184 r278  
    8383        query_size = atoi(getenv("CONTENT_LENGTH")); 
    8484 
    85         if (query_size > CGI_QUERY_MAX) 
     85        if (query_size > CGI_QUERY_MAX) { 
    8686            ows_error(o, OWS_ERROR_REQUEST_HTTP, "QUERY_STRING too long", 
    8787                      "request"); 
     88            return NULL; 
     89        } 
    8890 
    8991        query = malloc(sizeof(char) * CGI_QUERY_MAX); 
     
    210212                              "QUERY_STRING contains forbidden characters", 
    211213                              "request"); 
     214                    return NULL; 
    212215                } 
    213216            else { 
     
    224227                              "QUERY_STRING contains forbidden characters", 
    225228                              "request"); 
     229                    return NULL; 
    226230                } 
    227231            } 
     
    235239        ows_error(o, OWS_ERROR_REQUEST_HTTP, "QUERY_STRING too long", 
    236240                  "request"); 
     241        return NULL; 
    237242    } 
    238243 
     
    461466        ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, "xml isn't valid", 
    462467                  "request"); 
     468        return NULL; 
    463469    } 
    464470 
  • trunk/src/wfs/wfs_describe.c

    r255 r278  
    104104                    "Not a single layer is available. Check config file", 
    105105                    "describe"); 
     106            return; 
    106107    } 
    107108 
  • trunk/src/wfs/wfs_error.c

    r269 r278  
    6868    assert(locator != NULL); 
    6969 
     70    assert(!o->exit); 
     71    o->exit = true; 
     72 
     73    if (o->log != NULL) 
     74        fprintf(o->log, "[ERROR] {%s:%s} %s\n", 
     75        wfs_error_code_string(code), locator, message); 
     76 
    7077    fprintf(o->output, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); 
    7178    fprintf(o->output, "<ServiceExceptionReport\n"); 
     
    7986    fprintf(o->output, "</ServiceException>\n"); 
    8087    fprintf(o->output, "</ServiceExceptionReport>\n"); 
    81  
    82 #if TINYOWS_FCGI 
    83     OS_LibShutdown(); 
    84 #endif 
    85     if (o->log) fclose (o->log); 
    86     ows_free(o); 
    87  
    88     exit(EXIT_SUCCESS); 
    8988} 
    9089 
     
    101100    assert(locator != NULL); 
    102101 
     102    assert(!o->exit); 
     103    o->exit = true; 
     104 
     105    if (o->log != NULL) 
     106        fprintf(o->log, "[ERROR] {%s:%s} %s\n", 
     107        wfs_error_code_string(code), locator, message); 
     108 
    103109    fprintf(o->output, "<?xml version='1.0' encoding='UTF-8'?>\n"); 
    104110    fprintf(o->output, "<ExceptionReport\n"); 
     
    113119    fprintf(o->output, " </Exception>\n"); 
    114120    fprintf(o->output, "</ExceptionReport>\n"); 
    115  
    116 #if TINYOWS_FCGI 
    117     OS_LibShutdown(); 
    118 #endif 
    119     if (o->log) fclose (o->log); 
    120     ows_free(o); 
    121  
    122     exit(EXIT_SUCCESS); 
    123121} 
    124122 
  • trunk/src/wfs/wfs_get_feature.c

    r268 r278  
    651651                          "error : an id_column is required to use featureid", 
    652652                          "GetFeature"); 
     653                return NULL; 
    653654            } 
    654655        } 
     
    673674                    buffer_free(layer_name); 
    674675                    fe_error(o, fe); 
     676                    return NULL; 
    675677                } 
    676678 
     
    860862    /* retrieve a list of SQL requests from the GetFeature parameters */ 
    861863    request_list = wfs_retrieve_sql_request_list(o, wr); 
    862  
     864    if (!request_list) return; 
    863865        
    864866    if (wr->format == WFS_GML2 || wr->format == WFS_GML3) { 
  • trunk/src/wfs/wfs_request.c

    r259 r278  
    282282                wfs_error(o, wr, WFS_ERROR_LAYER_NOT_DEFINED, 
    283283                          "unknown layer name", "typename"); 
     284                return NULL; 
    284285            } 
    285286 
     
    291292                          "not-retrievable layer(s), GetFeature Operation impossible, change configuration file", 
    292293                          "typename"); 
     294                return NULL; 
    293295            } 
    294296 
     
    300302                          "not-writable layer(s), Transaction Operation impossible, change configuration file", 
    301303                          "typename"); 
     304                return NULL; 
    302305            } 
    303306        } 
     
    342345                      "featureid list size and typename list size must be similar", 
    343346                      ""); 
     347            return NULL; 
    344348        } 
    345349 
     
    361365                              "featureid values and typename values don't match", 
    362366                              ""); 
     367                    return NULL; 
    363368                } 
    364369            } 
     
    371376                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    372377                          "featureid must match layer.id", "GetFeature"); 
    373  
     378                return NULL; 
    374379            } 
    375380 
     
    390395                wfs_error(o, wr, WFS_ERROR_LAYER_NOT_DEFINED, 
    391396                          "unknown layer name", "GetFeature"); 
     397                return NULL; 
    392398            } 
    393399 
     
    401407                          "not-retrievable layer(s), GetFeature Operation impossible, change configuration file", 
    402408                          "GetFeature"); 
     409                return NULL; 
    403410            } 
    404411 
     
    412419                          "not-writable layer(s), Transaction Operation impossible, change configuration file", 
    413420                          "Transaction"); 
     421                return NULL; 
    414422            } 
    415423 
     
    459467                              "layers in TYPENAME must have the same SRS", 
    460468                              "GetFeature"); 
     469                    return; 
    461470                } 
    462471            } 
     
    468477                        "srsName value use an unsupported value, for requested layer(s)", 
    469478                        "GetFeature"); 
    470             } 
     479             return; 
     480        } 
    471481 
    472482    } else { 
     
    477487                        "srsName value use an unsupported value, for requested layer(s)", 
    478488                        "GetFeature"); 
    479              } 
     489             return; 
     490        } 
    480491    } 
    481492} 
     
    505516                  "Bad parameters for Bbox, must be Xmin,Ymin,Xmax,Ymax", 
    506517                  "NULL"); 
     518        return; 
    507519    } 
    508520 
     
    693705                  "propertyname list size and typename list size must be similar", 
    694706                  "GetFeature"); 
     707        return; 
    695708    } 
    696709 
     
    713726                              "propertyname values and typename values don't match", 
    714727                              "GetFeature"); 
     728                    return; 
    715729                } 
    716730 
     
    738752                ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    739753                          "propertyname values not available", "GetFeature"); 
     754                return; 
    740755            } 
    741756        } 
     
    764779    wr->filter = list_explode_start_end('(', ')', filter); 
    765780 
    766     if (wr->filter->size != wr->typename->size) { 
    767         buffer_free(filter); 
     781    if (wr->filter->size != wr->typename->size) 
    768782        wfs_error(o, wr, WFS_ERROR_INCORRECT_SIZE_PARAMETER, 
    769783                  "filter list size and typename list size must be similar", 
    770784                  "GetFeature"); 
    771     } 
    772785 
    773786    buffer_free(filter); 
     
    785798 
    786799    /* operation parameter is mandatory */ 
    787     if (!array_is_key(o->cgi, "operation"))  
     800    if (!array_is_key(o->cgi, "operation")) { 
    788801        ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    789802                  "Operation (Delete) must be specified", "Operation"); 
     803        return; 
     804    } 
    790805 
    791806    wr->operation = buffer_init(); 
    792807    buffer_copy(wr->operation, array_get(o->cgi, "operation")); 
    793808 
    794     if (buffer_cmp(wr->operation, "Delete") == false) 
     809    if (buffer_cmp(wr->operation, "Delete") == false) { 
    795810        ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    796811                  "only Delete operation is supported with GET method, use POST method for insert and update operations", 
    797812                  "Transaction"); 
     813        return; 
     814    } 
    798815} 
    799816 
     
    807824    assert(wr != NULL); 
    808825 
    809     if (!array_is_key(o->cgi, "typename") && !array_is_key(o->cgi, "featureid")) 
     826    if (!array_is_key(o->cgi, "typename") && !array_is_key(o->cgi, "featureid")) { 
    810827        ows_error(o, OWS_ERROR_MISSING_PARAMETER_VALUE, 
    811828                  "Typename or FeatureId must be set", "request"); 
     829        return; 
     830    } 
    812831 
    813832    /* test mutually exclusive parameters (filter,bbox and featureid) */ 
     
    870889        list_free(l); 
    871890        /* if versions weren't 1.0.0 or 1.1.0, raise an error */ 
    872         if (version == false) 
     891        if (version == false) { 
    873892            ows_error(o, OWS_ERROR_VERSION_NEGOTIATION_FAILED, 
    874893                      "VERSION parameter is not valid (use 1.0.0 or 1.1.0)", 
    875894                      "AcceptVersions"); 
     895            return; 
     896        } 
    876897 
    877898    } 
     
    881902        b = array_get(cgi, "updatesequence"); 
    882903 
    883         if (!buffer_cmp(b, "0")) 
     904        if (!buffer_cmp(b, "0")) { 
    884905            ows_error(o, OWS_ERROR_INVALID_UPDATE_SEQUENCE, 
    885906                      "updateSequence's value must be 0, UpdateSequence not available", 
    886907                      "updateSequence"); 
     908            return; 
     909        } 
    887910    } 
    888911 
     
    963986 
    964987    layer_name = list_init(); 
     988 
    965989    /* typename (requisite except if there is a featureid parameter */ 
    966     layer_name = wfs_request_check_typename(o, wr, layer_name); 
     990    if (!o->exit) layer_name = wfs_request_check_typename(o, wr, layer_name); 
    967991 
    968992    /* Featureid, if no typename defined, list of layer_name must be extracted from featureid */ 
    969     layer_name = wfs_request_check_fid(o, wr, layer_name); 
     993    if (!o->exit) layer_name = wfs_request_check_fid(o, wr, layer_name); 
    970994 
    971995    /* srsName */ 
    972     wfs_request_check_srs(o, wr, layer_name); 
     996    if (!o->exit) wfs_request_check_srs(o, wr, layer_name); 
    973997 
    974998    /* BBox : BBOX=xmin,ymin,xmax,ymax */ 
    975     wfs_request_check_bbox(o, wr, layer_name); 
     999    if (!o->exit)  wfs_request_check_bbox(o, wr, layer_name); 
    9761000 
    9771001    /* PropertyName */ 
    978     wfs_request_check_propertyname(o, wr, layer_name); 
    979     list_free(layer_name); 
     1002    if (!o->exit) wfs_request_check_propertyname(o, wr, layer_name); 
     1003 
     1004    if (!o->exit) list_free(layer_name); 
    9801005 
    9811006    /* outputFormat */ 
    982     wfs_request_check_output(o, wr); 
     1007    if (!o->exit) wfs_request_check_output(o, wr); 
    9831008 
    9841009    /* resultType */ 
    985     wfs_request_check_resulttype(o, wr); 
     1010    if (!o->exit) wfs_request_check_resulttype(o, wr); 
    9861011 
    9871012    /* sortBy */ 
    988     wfs_request_check_sortby(o, wr); 
     1013    if (!o->exit) wfs_request_check_sortby(o, wr); 
    9891014 
    9901015    /* maxFeatures */ 
    991     wfs_request_check_maxfeatures(o, wr); 
     1016    if (!o->exit) wfs_request_check_maxfeatures(o, wr); 
    9921017 
    9931018    /*Filter */ 
    994     wfs_request_check_filter(o, wr); 
     1019    if (!o->exit) wfs_request_check_filter(o, wr); 
    9951020} 
    9961021 
     
    10091034 
    10101035    /* general checks */ 
    1011     wfs_request_check_operation(o, wr); 
    1012     wfs_request_check_parameters(o, wr); 
     1036    if (!o->exit) wfs_request_check_operation(o, wr); 
     1037    if (!o->exit) wfs_request_check_parameters(o, wr); 
    10131038 
    10141039    layer_name = list_init(); 
    10151040    /* typename */ 
    1016     layer_name = wfs_request_check_typename(o, wr, layer_name); 
     1041    if (!o->exit) layer_name = wfs_request_check_typename(o, wr, layer_name); 
    10171042 
    10181043    /* featureid */ 
    1019     layer_name = wfs_request_check_fid(o, wr, layer_name); 
     1044    if (!o->exit) layer_name = wfs_request_check_fid(o, wr, layer_name); 
    10201045 
    10211046    /* bbox */ 
    1022     wfs_request_check_bbox(o, wr, layer_name); 
     1047    if (!o->exit) wfs_request_check_bbox(o, wr, layer_name); 
    10231048    list_free(layer_name); 
    10241049 
    10251050    /* filter */ 
    1026     wfs_request_check_filter(o, wr); 
     1051    if (!o->exit) wfs_request_check_filter(o, wr); 
    10271052} 
    10281053 
     
    10411066    b = array_get(cgi, "request"); 
    10421067 
    1043     if (o->request->service != WFS) 
     1068    if (o->request->service != WFS) { 
    10441069        ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    10451070                  "bad service, should be WFS", "SERVICE"); 
     1071        return; 
     1072    } 
    10461073 
    10471074    /* version */ 
    1048     if (!buffer_case_cmp(b, "GetCapabilities")) 
     1075    if (!buffer_case_cmp(b, "GetCapabilities")) { 
    10491076        wfs_request_check_version(o, wr, cgi); 
     1077        if (o->exit) return; 
     1078    } 
    10501079 
    10511080    /* check if request parameter is correct */ 
     
    11011130                if (buffer_cmp(wf->operation, "Delete")) 
    11021131                    wfs_delete(o, wf); 
    1103                 else 
     1132                else { 
    11041133                    ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    11051134                              "only Delete operation is supported with GET method, use POST method for insert and update operations", 
    11061135                              "Transaction"); 
     1136                    return; 
     1137                } 
    11071138 
    11081139            } else { 
     
    11101141                    op = array_get(o->cgi, "operations"); 
    11111142                    wfs_parse_operation(o, wf, op); 
    1112                 } else 
     1143                } else { 
    11131144                    ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 
    11141145                              "Operation parameter must be set", "Transaction"); 
     1146                    return; 
     1147                } 
    11151148            } 
    11161149 
  • trunk/src/wfs/wfs_transaction.c

    r257 r278  
    608608                          "error : an id_column is required to use featureid", 
    609609                          "Delete"); 
     610                return; 
    610611            } 
    611612        } 
     
    920921        xmlCleanupParser(); 
    921922        wfs_error(o, wr, WFS_ERROR_NO_MATCHING, "xml isn't valid", "transaction"); 
     923        return; 
    922924    } 
    923925