Permalink
Browse files

Do more validation on returned WMS GetMap results (#149)

- fail on non 2XX HTTP status codes
- fail if returned image is not of the requested size
  • Loading branch information...
tbonfort committed Aug 11, 2016
1 parent 9f29bfb commit 91c7d9aa143045ed4492b5d622e847e439316dda
Showing with 10 additions and 2 deletions.
  1. +4 −2 lib/http.c
  2. +6 −0 lib/image.c
View
@@ -156,12 +156,14 @@ void mapcache_http_do_request(mapcache_context *ctx, mapcache_http *req, mapcach
if(req->post_body && req->post_len>0) {
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, req->post_body);
}
if(!http_code)
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
/* get it! */
ret = curl_easy_perform(curl_handle);
if(http_code)
curl_easy_getinfo (curl_handle, CURLINFO_RESPONSE_CODE, http_code);
else
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
if(ret != CURLE_OK) {
ctx->set_error(ctx, 502, "curl failed to request url %s : %s", req->url, error_msg);
View
@@ -291,6 +291,12 @@ void mapcache_image_metatile_split(mapcache_context *ctx, mapcache_metatile *mt)
ctx->set_error(ctx, 500, "failed to load image data from metatile");
return;
}
if(metatile->w != mt->map.width ||
metatile->h != mt->map.height) {
ctx->set_error(ctx, 500, "image size does not correspond to metatile size");
return;
}
for(i=0; i<mt->metasize_x; i++) {
for(j=0; j<mt->metasize_y; j++) {
tileimg = mapcache_image_create(ctx);

0 comments on commit 91c7d9a

Please sign in to comment.