#include "cgic.h" /* Change this, if necessary, to point to the location of the sendmail binary on your system. */ #define SENDMAIL "/lib/sendmail -t" /* CHANGE THIS to your email address. */ #define RECIPIENT "CHANGE@ADDRESS.COM" int cgiMain() { /* Large enough buffers for any reasonable real name and email address. */ char name[256]; char email[256]; /* The version "number". */ char version[32]; /* The user's system. */ char userSystem[32]; /* The bug report itself may be quite large, so we'll allocate space once we know how large it is. */ char *bug; /* Space needed for the bug string. */ int needed; /* Keep the results so we can complain if fields are missing. */ int rName, rEmail, rComments, rVersion, rSystem; FILE *out; /* Output the usual MIME header. */ cgiHeaderContentType("text/html"); /* Start the HTML document. */ fprintf(cgiOut, "\n
\n"); /* cgiFormStringNoNewlines() will never overflow buffers or write a non-terminated string. Also, even if the user's browser is defective, it will not return any carriage returns or line feeds. */ rName = cgiFormStringNoNewlines("name", name, sizeof(name)); rEmail = cgiFormStringNoNewlines("email", email, sizeof(email)); /* A "falsified" version number would not particularly matter in this case, so we'll just get the string instead of using cgiFormSelectSingle. */ rVersion = cgiFormStringNoNewlines("version", version, sizeof(version)); /* The same goes for the system. */ rSystem = cgiFormStringNoNewlines("system", userSystem, sizeof(userSystem)); /* cgiFormStringSpaceNeeded returns the number of bytes of space guaranteed to be adequate for the string in question, including the terminating null. */ rComments = cgiFormStringSpaceNeeded("bug", &needed); /* Now check for missing fields. Since any well-behaved browser will submit the default for each option menu if nothing was actually chosen by the user, we check for the "PLEASE CHOOSE ONE" strings as well as for a missing field. */ if ((rName == cgiFormNotFound) || (rEmail == cgiFormNotFound) || (rComments == cgiFormNotFound) || (rSystem == cgiFormNotFound) || (rVersion == cgiFormNotFound) || (!strcmp(userSystem, "PLEASE CHOOSE ONE")) || (!strcmp(version, "PLEASE CHOOSE ONE"))) { /* If any field is missing, complain! */ fprintf(cgiOut, "