Modify

Opened 8 years ago

Closed 8 years ago

Last modified 4 years ago

#7158 closed defect (worksforme)

uhttpd not handle cgi output properly

Reported by: dzuy@… Owned by: developers
Priority: high Milestone: Barrier Breaker 14.07
Component: packages Version: Trunk
Keywords: uhttpd Cc:

Description

When executing a simple cgi script, my browser keeps telling me that it's a BIN file even though I specify it's a text/plain content type. Here is a real simple cgi script:

#!/bin/sh

echo "Content-Type: text/plain"
echo ""
echo "foo"

The problem is with uhttpd-cgi.c line 477:

ensure(uh_http_send(cl, req, &hdr[hdroff], hdrlen - hdroff));

(hdrlen - hdroff) is 1 longer than the buffer being sent. Since the uh_http_send() function calculates the length of the buffer before sending it out, just call

ensure(uh_http_send(cl, req, &hdr[hdroff], -1));

should do it.

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by jow

  • Resolution set to worksforme
  • Status changed from new to closed

I cannot verify your problem, the provided example works as expected
without modifications to the httpd source.

Make sure your line endings are correct (\r\n vs. \n) and that there is
no trailing whitespace around.

A more clean way to specify the header is:

echo -en "Content-Type: text/plain\r\n\r\n"
echo "Content..."

comment:2 Changed 8 years ago by anonymous

Thanks for the hint!!

comment:3 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.