Opened 18 years ago

Closed 18 years ago

#1628 closed defect (fixed)

Content-type in Post Requests

Reported by: silke.reimer@… Owned by: sdlime
Priority: high Milestone:
Component: MapServer CGI Version: 4.8
Severity: normal Keywords:
Cc:

Description

When the client doesn't send an content-type in the HTTP-header mapserver
segfaults. The patch below fixes the problem.

diff -ur mapserver-4.8.0-rc2/cgiutil.c mapserver-4.8.0-rc2.new/cgiutil.c
--- mapserver-4.8.0-rc2/cgiutil.c       2006-01-26 15:00:33.000000000 +0100
+++ mapserver-4.8.0-rc2.new/cgiutil.c   2006-01-26 15:00:26.000000000 +0100
@@ -129,9 +129,14 @@
     char *post_data;

     request->type = MS_POST_REQUEST;
-    request->contenttype = strdup(getenv("CONTENT_TYPE"));
-
     post_data = readPostBody( request );
+    if (s = getenv("CONTENT_TYPE"))
+       request->contenttype = strdup(s);
+    /* we've to set default content-type which is
+     * application/octet-stream according to
+     * W3 RFC 2626 section 7.2.1 */
+    else request->contenttype = "application/octet-stream";
+
     if(strcmp(request->contenttype, "application/x-www-form-urlencoded"))
         request->postrequest = post_data;
     else

Change History (5)

comment:1 by dmorissette, 18 years ago

Cc: dmorissette@… added

comment:2 by sdlime, 18 years ago

For whatever reason the patch below bombs on my machine. I think there's a small
problem. Shouldn't:

  request->contenttype = "application/octet-stream";

be:

  request->contenttype = strdup("application/octet-stream");

to avoid problems when free'ing request->contenttype later?

Steve

comment:3 by sdlime, 18 years ago

Status: newassigned

comment:4 by silke.reimer@…, 18 years ago

Yes, I think you are right. Could you please change the patch accordingly?

Does this solve your problem with this patch?

Silke

comment:5 by sdlime, 18 years ago

Resolution: fixed
Status: assignedclosed
I tweaked the patch and applied to CVS HEAD and 4.8. Thanks for your help on
this one Silke. Marking as fixed.

Steve
Note: See TracTickets for help on using tickets.