Skip to content

Commit

Permalink
democlient: handle input through QUERY_STRING if stdin doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Nov 28, 2012
1 parent 40719c5 commit 7190443
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions democlient/democlient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ class CppcheckExecutor : public ErrorLogger {

int main()
{
const char *lenstr = getenv("CONTENT_LENGTH");
char data[4096] = {0};
int len = std::min(1 + atoi(lenstr), (int)(sizeof(data) - 2));
fgets(data, len, stdin);

const char *lenstr = getenv("CONTENT_LENGTH");
if (lenstr) {
int len = std::min(1 + atoi(lenstr), (int)(sizeof(data) - 2));
fgets(data, len, stdin);
} else {
const char *s = getenv("QUERY_STRING");
strncpy(data, s?s:"", sizeof(data)-2);
}

char code[4096] = {0};
unencode(data, code);
Expand Down

0 comments on commit 7190443

Please sign in to comment.