You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by John Volanthen <jo...@jft.co.uk> on 1999/01/16 13:19:01 UTC

mod_cgi/3689: Multipart mime messages cannot be read properly on NT / Win32

>Number:         3689
>Category:       mod_cgi
>Synopsis:       Multipart mime messages cannot be read properly on NT / Win32
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Sat Jan 16 04:20:01 PST 1999
>Last-Modified:
>Originator:     john@jft.co.uk
>Organization:
apache
>Release:        1.3.4
>Environment:
NT4 SP3, pre-compiled binary
>Description:
I am porting a ".c" CGI program from Linux to Win32, things work OK on Linux, but 
on Win32 (using standard CGI).

I am using multipart mime to send 2 files to the CGI program. when I send 
more than about 64Kb of data The "connection reset by peer "message is displayed 
on the browser. When sending to the same program on Linux all works OK.

If I send about 20Kb of data, the number of bytes I am able to read is always less 
than the CONTENT_LENGTH variable indicates. This happens for all browsers I have tried
Tried
>How-To-Repeat:
CODE FRAGMENT :


/******************************** ReadInData *********************************/
void ReadInData()
{
char Buffer[1024];			/* input buffer */
char delimeter[255];			/* the delimeter */
int  delLength;				/* length of delimeter */
char contentInfo[255];			/* the content info string */
char name[255];								/* Name of the current item */
int  i,j;
char *ptmp;
int dataSize;								/* size of data in 1k blocks */
int ContentLength;
int ActuallyRead;


  ptmp = getenv("CONTENT_TYPE");			/* get and verify the content  type */
  if (!ptmp){
    SEND_HTTP_HEADERS;
    printf("%s",INITIAL);
    fatal(54,0,TRUE);
  }
  if(!strstr(ptmp,"multipart")){
    SEND_HTTP_HEADERS;
    printf("%s",INITIAL);
    fatal(54,0,TRUE);
  }
  ptmp = getenv("CONTENT_LENGTH");			/* get and verify the content length */
  if (!ptmp){
    SEND_HTTP_HEADERS;
    printf("%s",INITIAL);
    fatal(54,0,TRUE);
  }
  ContentLength = atoi(ptmp);
  if (ContentLength ==0){
    SEND_HTTP_HEADERS;
    printf("%s",INITIAL);
    fatal(54,0,TRUE);
  }
 
  printf("Expecting %d<hr>\n",ContentLength);


  ptmp = (char *)malloc (1 + (ContentLength));
  if (!ptmp){
    SEND_HTTP_HEADERS;
    printf("%s",INITIAL);		/* USE xmalloc here TODO */
    fatal(100,0,TRUE);
  }

  ActuallyRead = read (fileno (stdin), ptmp, ContentLength);
  ptmp[ActuallyRead] = '\0';
  printf("Actually Read %d<hr>\n",ActuallyRead);
  printf("%s",ptmp);
 
  return;
}
>Fix:
No Idea, sorry ....
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]