Skip to content

Commit

Permalink
Correcting mapscript methods msIO_stripStdoutBufferContentType() and …
Browse files Browse the repository at this point in the history
…msIO_stripStdoutBufferContentHeaders() for new line endings (MapServer#4430).
  • Loading branch information
Schpidi committed Sep 26, 2012
1 parent 498fa11 commit 0aefa14
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions mapio.c
Expand Up @@ -784,7 +784,8 @@ char *msIO_stripStdoutBufferContentType()
/* -------------------------------------------------------------------- */
end_of_ct = 13;
while( end_of_ct+1 < buf->data_offset
&& buf->data[end_of_ct+1] != 10 )
&& buf->data[end_of_ct+1] != 10
&& buf->data[end_of_ct+1] != '\r' )
end_of_ct++;

if( end_of_ct+1 == buf->data_offset ) {
Expand All @@ -794,22 +795,21 @@ char *msIO_stripStdoutBufferContentType()
}

/* -------------------------------------------------------------------- */
/* Continue on to the start of data ... skipping two newline */
/* markers. */
/* Continue on to the start of data ... */
/* Go to next line and skip if empty. */
/* -------------------------------------------------------------------- */
start_of_data = end_of_ct+2;
while( start_of_data < buf->data_offset
&& buf->data[start_of_data] != 10 )
start_of_data++;

start_of_data = end_of_ct+3;
if( start_of_data < buf->data_offset
&& ( buf->data[start_of_data] == 10
|| buf->data[start_of_data] == '\r' ) )
start_of_data +=2;

if( start_of_data == buf->data_offset ) {
msSetError( MS_MISCERR, "Corrupt Content-type header.",
"msIO_stripStdoutBufferContentType" );
return NULL;
}

start_of_data++;

/* -------------------------------------------------------------------- */
/* Copy out content type. */
/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -870,33 +870,36 @@ void msIO_stripStdoutBufferContentHeaders()
/* -------------------------------------------------------------------- */
start_of_data +=7;
while( start_of_data+1 < buf->data_offset
&& buf->data[start_of_data+1] != 10 )
&& buf->data[start_of_data+1] != 10
&& buf->data[start_of_data+1] != '\r' )
start_of_data++;

if( start_of_data+1 == buf->data_offset ) {
msSetError( MS_MISCERR, "Corrupt Content-* header.",
"msIO_stripStdoutBufferContentHeaders" );
return;
}
start_of_data +=2;
/* -------------------------------------------------------------------- */
/* Go to next line. */
/* -------------------------------------------------------------------- */
start_of_data +=3;
}

/* -------------------------------------------------------------------- */
/* Continue on to the start of data ... skipping two newline */
/* markers. */
/* Continue on to the start of data ... */
/* Skip next line if empty. */
/* -------------------------------------------------------------------- */
while( start_of_data < buf->data_offset
&& buf->data[start_of_data] != 10 )
start_of_data++;
if( start_of_data < buf->data_offset
&& ( buf->data[start_of_data] == 10
|| buf->data[start_of_data] == '\r' ) )
start_of_data +=2;

if( start_of_data == buf->data_offset ) {
msSetError( MS_MISCERR, "Corrupt Content-* header.",
"msIO_stripStdoutBufferContentHeaders" );
return;
}

start_of_data++;

/* -------------------------------------------------------------------- */
/* Move data to front of buffer, and reset length. */
/* -------------------------------------------------------------------- */
Expand Down

0 comments on commit 0aefa14

Please sign in to comment.